a dirty area of the room. The code
fragment in Figure 2 shows how
easily this can be done in
area. A meter in the upper-left corner displays the status of
the robot’s battery. The robot’s charging station is located
in the lower right corner of the figure. It is assumed that
the robot must back into the charger in order to make the
required electrical connections.
Our vision of the robot’s behavior was straightforward.
Normally, the robot should roam randomly throughout the
room, hoping to vacuum the entire floor through accidental
encounters. Periodically, the robot should acquire a picture
of the room through a ceiling mounted camera. Although
RobotBASIC does have commands for acquiring pictures
from a web cam, this action was simulated by capturing the
screen with commands designed for that purpose.
Once an image of the environment is obtained, the
robot should search it for ‘dirt.’ If some is found, the robot
should navigate to that area of the room and clean that
area with appropriate movements. While all this is
happening, the robot should monitor its internal battery. If
the charge becomes low, the robot should temporarily
abandon its current behavior and make its way to the
charger. These actions of the robot may sound simple, but
the details of carrying them out can be complex, as
The simulated robot in
RobotBASIC has commands that
indicate the robot’s position in the
room. A real robot would have to
obtain this information from a GPS or LPS (Local Positioning
System). Once the robot knows the coordinates of the dirt
and its own location in the room, trigonometry can be used
to determine where the dirt is in respect to the robot itself.
With this information, the robot can use its electronic
compass (also available on the simulated robot) to turn to
face the dirt.
Finding the Charger
• How does the robot analyze the image of the room
to find the dirt?
• Once dirt is located, how does the robot determine
how to move from its current location to the debris?
• How does the robot find the charger and orient itself
to obtain the charge?
• When the robot is moving to the soiled spot or to
the charger, how does it deal with objects blocking
The charger could be found using methods similar to
those used to navigate to the dirt. For the sake of diversity
though, let’s use a different approach. First, we will assume
that there is a line on the floor that the robot can follow to
the charging terminals (see Figure 1 again). The line will
have a loop on its free end so that if the robot finds the
line and follows it, it will always end up at the charger.
Furthermore, because the robot is following the line, it will
always be pointed directly at the charging terminals when
the charger is encountered. The robot can then connect to
the charger by rotating 180º and backing up.
Of course, for this to work, the robot must be able to
find the line. For that reason, a beacon (perhaps a cluster
of IR diodes pulsing at a detectable frequency) will be
placed on the ceiling over the line. The robot can face the
beacon and then move forward looking for the line. During
this movement — as with movement towards dirt — the
robot must deal with obstacles that block its path.
Let’s examine each of the above situations.
Locating the Dirt
38 SERVO 02.2011
Since our simulation assumes a sensor exists to detect
the litter, we will assume that images of the room will show
the dirt in a particular color. RobotBASIC has a command
that divides an image into a user-defined matrix and
supplies information about the amount of any specified
color found in each of the matrix segments. Using this
command, a program can determine the x,y coordinates of
If you were walking through a room toward some
destination and were blocked by an obstacle, what would
you do? The most likely solution is to go around the object
blocking your path and this is exactly what we want our
vacuuming robot to do.