Datasheet
Chapter 7 • Navigating with Infrared Headlights
240 • Robotics with the BOE Shield-Bot
If you want to try a tabletop:
Try an electrical tape or paint course first!
Remember to follow the same steps you followed before running the BOE Shield-
Bot in the electrical tape or paint delimited course!
Always be ready to pick your BOE Shield-Bot up from above as it approaches the
edge of the table it’s navigating. If the BOE Shield-Bot tries to drive off the edge,
pick it up before it takes the plunge. Otherwise, your Shield-Bot might become a
Not-Bot!
Your BOE Shield-Bot may detect you if you are standing in its line of sight. Its
current sketch has no way to differentiate you from the table below it, so it might
try to continue forward and off the edge of the table. So, stay out of its detector’s
line of sight as you spot.
Example Sketch: AvoidTableEdge
For the most part, programming your BOE Shield-Bot to navigate around a tabletop without
going over the edge is a matter of adjusting the
if...else if...else statements from
FastIrRoaming. First of all, instead of backing up, it will need to go forward 20 ms at a time
when it sees objects with both detectors. It will also need to turn toward objects instead of
away from them, and it will need to turn for more than 20 ms when it sees the drop-off. 375
ms turns seem to work well, but it will be up to you to adjust that value for best
performance.
Open FastIrNavigation and save it as AvoidTableEdge.
Modify the sketch so that it matches the Example Sketch. Pay close attention to
the conditions and
maneuver calls in the loop function. The condition that used
to go forward for 20 ms now backs up for 250 ms. Likewise, the condition that
used to back up now goes forward for 20 ms. Also, the condition that used to call
for a 20 ms right turn now calls for a 375 ms left turn, and the condition that used
to call for a 20 ms left turn now calls for a 375 ms right turn.
Test the sketch on your electrical tape or paint delimited course.
If you decide to try a tabletop, remember to follow the testing and spotting tips
discussed earlier.
/*
* Robotics with the BOE Shield - AvoidTableEdge
* Adaptation of FastIrRoaming for table edge avoidance
*/
#include <Servo.h> // Include servo library
Servo servoLeft; // Declare left and right servos
Servo servoRight;