The maximum number of correct code
matches is 36. As you can see from Figure
4, when the robot is relatively close to its
starting position, the number of matches is
high; at least 24 in this example, averaging
26. 4. When remote locations are
compared, their signatures are lower, with
scores of 20 or less, averaging 17. 7.
Using a Real Robot
A simulated robot provides an easy
way to test the ideas presented here, but
we need a real world example to verify the
validity of the simulation. I used a modified
Parallax Scribbler S3 (see Figure 5) with
PING))) ranging capability (as discussed in
the March 2018 issue of SERVO) to
perform some real world scans, although
you could use any hobby robot with
ranging capability. The S3 currently doesn’t
have a compass, so the robot was
physically placed at a variety of positions in
a make-shift environment.
Figure 6 shows the results of five
scans with the S3. Again, the asterisks
show where the signatures should match.
for i=1 to 36
if substring(S1,i,1) = substring(S2,i,1) then
// face north
// take readings
for c = 0 to 35
// create code
Code = ""
for c = 0 to 35
pnt2 = c+1
if pnt2 > 35 then pnt2 = 0
Code = Code+"S"
Code = Code+"h"
Code = Code+"H"
Code = Code+"l"
Code = Code+"L"
Code = Code+"V" // very large increase
Code = Code+"v" // very large decrease
For these readings, the robot was moved
from its original location a distance approximately equal to
its diameter. In all three cases, the readings were very high
( 27, 26, and 23). When the robot was moved a significant
distance (about 40 inches in this case), the signature
comparison dropped to 13. Notice that these readings are
very similar to that obtained during simulation, verifying its
In my tests, the range comparisons were considered
the same if new readings were within 15% of the previous
reading. Values differing between 15% and 30% were
considered moderate, and those between 30% and 50%
were considered significant. Anything larger is considered a
very large change, as discussed earlier. All of these
parameters are controlled by variables that can be easily
changed for experimentation as shown in Figure 8.
The code fragment in Figure 9 shows how the
signature is formed from the algorithm discussed earlier.
The routine in Figure 10 shows how easy it is to compare
two signatures. Readers wanting a copy of the entire
program can get it with the article downloads or from the
In The News tab at www.RobotBASIC.org.
Obviously, the algorithm discussed here has potential,
but it certainly needs more work to become a complete
system. The simulation makes such experimentation easy,
quick, and inexpensive.
One of the reasons the results from the simulation and
the real robot agree so well is that care was taken to
ensure the simulation properly mimicked the scanning
properties of the S3. This is especially important because
RobotBASIC’s simulated robot performs a ranging scan in a
very narrow beam (like a laser). The PING))) rangers, on the
other hand, have a wide beam width.
To provide compatibility, a special routine was written
(see Figure 7) that allows the user to specify the simulator’s
beam width by passing the left and right angles (a1 and
Improving Performance with Experimentation
SERVO 05/06.2018 39
Keep in mind that in the real world, many factors —
such as the robot’s environment and the type of ranging
sensor used — could affect the system’s performance. Even
so, if your next project requires a local positioning system,
you might give this a try. SV