Page 356 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 356
Amphibionics 07 3/24/03 9:13 AM Page 335
Chapter 7 / Turtletron: Build Your Own Robotic Turtle
around the room until distance readings from the sonar module
alerted the robot that an evasive maneuver was needed to avoid
crashing into an obstacle.
To improve this situation, the robot will need to create a rudimen-
tary map of the area surrounding its current position. A robot’s
ability to create an internal representation of the external world
can be thought of as the first measure of machine intelligence, and
is a necessary evolutionary step to self awareness and conscious-
ness. The final program in this chapter will take advantage of the
optical shaft encoder and the ultrasonic range finder to give the
robot the ability to map the area around itself and store the results
internally. Based on this information, the robot can then make an
intelligent decision about where to move.
This is accomplished by having the robot take a series of distance
measurements in a 180-degree arc to the front and sides of its cur-
rent location. From where the robot is facing, it will rotate 90
degrees to the left and then start taking distance measurements as
it rotates back in the opposite direction for 180 degrees. The dis-
tance measurements are stored in a one-dimensional array called
position, made up of 12 elements. To make sure that the robot is
consistently moving the same distance for each sonar measure-
ment taken, the output from the optical encoder circuit is used.
The motor control algorithm works by first reading the current
state of the sensor. The initial state of the sensor doesn’t matter;
we are concerned with when the sensor changes from its current
state, indicating that the wheel has moved 1/12 of a complete
rotation. Using this method makes motor control and wheel track-
ing uncomplicated. The program takes the current state of the sen-
sor and stores it in a variable. The motor is then moved by a very
small amount, and the stored sensor state is then compared to the
current state. If the two states are the same, then the motor is
moved again by a small amount. This continues until the sensor
has changed from its original state, at which time the motor is
335

