Page 357 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 357
Amphibionics 07 3/24/03 9:13 AM Page 336
stopped and the next sonar distance reading is taken. This indi-
cates that the motor has moved the wheel by 1/12 of a complete
rotation. Amphibionics
When all of the sonar distance measurements have been taken, a
sorting algorithm determines which position contains the distance
measurement with the highest value. The robot is then rotated
back to the position with the greatest amount of free space, and
then moves forward to map out the surrounding area. If an obsta-
cle is encountered while moving forward, the robot backs up and
makes another map to determine the best route to take. Compile
sonar-map.bas, listed in Program 7.13, and then program the PIC
16F84 with the corresponding sonar-map.hex file, listed in
Program 7.14.
I find this final experiment to be a lot of fun because of the speed
at which the robot scans the area while making maps, and how
fast it can travel through a room. It is very surprising to see how
well the robot can maneuver through rooms and consistently pick
the areas with the most free space.
To develop robotic room mapping further, write a program that
stores the distance readings in a two-dimensional array. This way
the robot would be able to quickly backtrack without having to
take sonar readings for an area that it has already explored.
'------------------------------------------------------------------------------------------------------------------------------
PROGRAM 7.13
' Name : sonar-map.bas
sonar-map.bas program
' Compiler : PicBasic Pro - MicroEngineering Labs
listing
' Notes : Room mapping using the sonar ranger and
' : incremental shaft encoder.
'------------------------------------------------------------------------------------------------------------------------------
' PortA set as outputs. Pin 1 input.
trisa = %00000010
' PortB set as outputs. pin 0 input.
336

