The real robot was placed on the floor in my office
with a chair and two cases serving as obstacles, as shown
in Figure 6. When the modified program was run, it
produced the output in Figure 7. Notice the scan shows
for Beginners By John Blankenship
Part 2: Adding Sensors
rCommand (SensorSetup, PING)
angle = -90
for i=1 to 10
r = rRange()
rTurn -90 // original position
PortNum = 5 // set to your Bluetooth Port
end Figure 4.
The output from this program
is shown in Figure 5. This could be
the beginning of a program that maps the robot’s
environment, so it can formulate a path to avoid objects.
the range reading is greater than 10.
Refer to last month’s article for additional details about
programs like this.
Scans with the Real Robot
Reducing Development Time
One of the great things about using an RROS-based
robot is that you can reduce your development time using
RobotBASIC’s robot simulator. Figure 4 shows a program
that demonstrates how this works.
SERVO 01.2018 43
To post comments on this article and find any
associated files and/or downloads, go to
This same program can be used to control a real robot.
All we need to do is initialize the actual robot as previously
demonstrated. This is easily done by replacing the original
three lines that located the simulated robot and drew the
two obstacles with gosub InitDCrobot.
It locates the simulated robot in the center of the
screen and draws two obstacles within the environment.
The robot then rotates to the left 90° before turning right
in 20° increments. At each position, it takes an rRange()
reading and draws a line whose
length is proportional to the
distance measured, extending
forward from the robot’s current
The program was easy to
develop on the simulator because
of the instant feedback. You know
immediately if the robot is not
turning correctly or if faulty math is
drawing the scan lines improperly.