i, randy

Skip to Page 1 2 3 4

Building the Maze

Next I added a side-looking Sharp IR sensor and a Handy Cricket for a brain, and started the fun part - programming and testing. But to test navigation, it soon became obvious that I would need a maze. The nice thing about dead reckoning is that you don't need all the walls, because (in theory) it knows where it is at all times, and it knows where the walls should be.

So I went about taping out a maze on my basement floor. It was quite a feat just to clear out an 8' x 8' space! Here's a shot of the maze after tape-out:

The pieces of wood are placed in key areas where I have determined it would be wise to do a "sanity check," or what is more correctly called "localization." So it knows where it is, but every dead-reckoning system drifts, and needs to be corrected periodically with the aid of sensors that read it's immediate proximity to known landmarks.

Programming the Robot

As I mentioned in the intro, I planned to use Cricket Logo to program the bot. This turned out to be, as I thought, a really fun language for this kind of thing. Here's the core routine, called "deadreck", that runs when you push the button:

  to deadreck
  ;Navigate maze using dead reckoning,
  ;with corrections from IR sensors
  ;CAL VALUE: dist from right when center=9 in. from wall
  setrtcal 140
  gxinit	; Initialize Gamatronix Gamoto motor controllers
  setv 4000 ; Set max velocity for all trajectories
  seta 8	; Set acceleration for all trajectories
  settrajs	; Set up trajectories using above parameters
  fwd 41	; forward 41 inches.
  correct_rt ; Set offset global, based on distance from wall
  left 90	; left 90 degrees
  fwd 28
  correct_rt
  left 90
  fwd 15 ;Enter room 1
  right 30
  left_spinsearch 150
  left 60
  setoffset 0
  fwd 15 ;Exit room 1
  left 90
  fwd 19
  correct_rt
  setoffset2 offset
  left 90
  correct_rt
  setx offset
  setoffset offset2
  setoffset2 x
  fwd 23
  right 90
  setoffset (0 - offset2)
  fwd 11
  correct_rt
  setoffset2 offset
  setoffset 0
  fwd 19
  ;correct_fwd
  right 90
  setoffset (0 - offset2)
  fwd 15 ;Enter room 2
  left 30
  right_spinsearch 150
  right 60
  setoffset 0
  fwd 15 ;Exit room 2
  correct_rt
  setoffset3 offset
  left 90
  correct_rt
  setoffset2 offset
  setoffset offset3
  fwd 30
  right 90
  setoffset (0 - offset2)
  fwd 35
  correct_rt
  left 90
  fwd 15 ;Enter room 3
  left 30
  right_spinsearch 150
  right 60
  setoffset 0
  fwd 15 ;Exit room 3
  left 90
  fwd 18
  right 90
  fwd 15 ;Enter room 4
  left 30
  right_spinsearch 150
  right 60
  fwd 15 ;Exit room 4
  correct_rt
  left 90
  fwd 36
  right 180
  correct_rt
  left 95
  fwd 48 ;HOME!
  correct_rt
  left 90
  fwd 0
  beep
  wait 50
  deadreck ;do it again
  end
  

Here's another shot of the maze from a lower angle:

So now, after many many hours of programming and tweaking, I made a video of the robot going through the entire maze. It's a huge file (23Mb), because it's a minute and a half long, but it's fun to watch it navigate the entire maze without hitting anything.

Download the Quicktime movie here.

HOME