that point, the robot simply repeats its actions: face the
desired destination; move forward until blocked by an
object (or until the destination is reached); and (if an object
is encountered) move around the object a random distance.
If this sequence of actions is repeated over and over,
eventually the robot will arrive at its intended destination.
This obstacle-avoidance behavior will be used when the
robot is moving towards dirt or towards the beacon to find
Putting It All Together
Since RobotBASIC’s simulated robot has all the sensors
discussed in this article, it was easy to implement a
program to test the algorithm described here. The robot
behaves as expected, wandering randomly around the room
unless the ceiling camera spots dirt. When the robot’s
battery runs low, it abandons its current behavior and
makes its way to the charger, follows the line, and backs
itself into position. When the charge is complete (as shown
on the simulated meter), the robot continues the task that
was interrupted by the need to recharge.
The program allows the user to use the mouse to
sprinkle dirt around the room. There is even an option for
letting the robot leave a trail to show where it has
vacuumed. Figure 3 shows how much of the room was
actually covered after the robot spent some time cleaning.
Of course, you may have a totally different idea of how
a vacuuming robot should operate. That is the beauty of
simulations. You can improve on ideas or develop a totally
new approach of your own. And, since RobotBASIC also
has commands for controlling real robots, you will have a
head start toward building a real vacuuming system.
The fully commented source code for the simulation
described here can be downloaded from the APPLICATIONS
page at www.RobotBASIC.com. SV
SERVO 02.2011 39