By John Blankenship
Let’s look at one
example of how we
might verify the
operation of the
simulator’s line
for Your Robot
(as you will see) will need a second intersecting line. In
addition, we will need a wall for testing the ranging sensors
and a beacon for testing the beacon sensors. Figure 1
shows the test environment I used for the simulator. It is
composed of two lines on the floor that
intersect at right angles. There is also a
wall at the top of the figure and a
beacon on the right. The robot’s
starting position should be centered on
the intersecting lines with all of the line sensors (which are
on the front edge of the simulated robot) on the line
directed toward the wall. Notice the simulated robot in the
figure is placed in this position.
positioned over it. The test software
should display the sensor readings so
you can ensure that the robot is
correctly centered on the line.
Figure 1
Some of the tests for other sensors
SERVO 12.2016 39
Post comments on this section and find any associated files and/or downloads at
www.servomagazine.com/index.php/magazine/article/December2016_Robot-Self-Diagnostics.
xyString 350,335,"TEST RESULTS"
// verify all the sensors are ON
// note: rSense() returns the three line sensor readings as a 3-bit value
if rSense() <> 7
xyString 5,355,"The line sensors should be all on (assuming you setup the robot properly)."
xyString 5,375,"They are reporting a ",rSense()," so they have failed."
xyString 5,395,"Fix the problem and rerun the test."
gosub StopTesting
endif
// test to see if the sensors will turn OFF
rTurn -45
gosub ShowSensors
if rSense()=0
xyString 5,355,"The line sensors seem to be working properly."
xyString 5,375,"All sensors will turn on and off."
else
xyString 5,355,"If the robot has turned away from the line, the line sensors are not"
xyString 5,375,"working properly. Currently they should be all off, but they read ",rSense(),"."
xyString 5,400,"Fix the line sensors and rerun this test program."
xyString 5,420,"NOTE: If the robot has not moved away from the line, then the motors"
xyString 5,440," must be fixed before the tests can continue."
gosub StopTesting
endif
rTurn 45
gosub ShowSensors
// now move robot back to setup position
if rSense() = 0 // not even close to line
xyString 5,395,"The robot however, could not find the line again. Perhaps there"
xyString 5,415,"is a problem with the encoders. The robot must be able to move"
xyString 5,435,"reasonably accuratley to run the tests."
xyString 5,455,"Fix the problem and rerun this test program."
gosub StopTesting
endif
// some of the line sensors are on the line
// make tiny movements to get all sensors back on the line
LT = 0
num = 0 // count the number of tries it takes to find the line again
for i=1 to 20
if rSense() = 0 then rTurn LT\LT=0 // reverse movement if line lost
if rSense() = 1 then rTurn 1\LT=-1
if rSense() = 3 then rTurn 1\LT=-1
if rSense() = 6 then rTurn -1\LT=1
if rSense() = 4 then rTurn -1\LT=1
gosub ShowSensors
num++
if rSense()=7 then break
next
// check ability to find the line again
if num>5 // some problem is likely if more than 5 tries are needed
xyString 5,395,"The robot, however, took too long to find the line again."
xyString 5,415,"Perhaps the motors are too fast or too slow."
xyString 5,435,"The robot must be able to move reasonably"
xyString 5,455,"accuratley to run the test. "
xyString 5,475,"Fix the problem rerun this test program."
gosub StopTesting
else
// complete the report that the line sensors appear to be working correctly
xyString 295,375," and they were used to find the line again."
endif
Figure 2
The environment
for a real robot might
be lines composed of
black electrical tape
on a white poster
board that is placed
against a wall in your
home. Of course, the
environment you use
will be unique for
your robot and the
sensors it uses. It is
unlikely that your
robot will have the
same sensors as the
simulator and even if
it does, differences in
the mounting
configurations could
force your testing
procedures to be
different from any
shown here. Ideally
though, the principles
and concepts
demonstrated by the
simulator test
program will help you
create something
that meets your
needs.
Testing the
Line
Sensors