28125 Parallax Inc, 28125 Datasheet - Page 196

TEXT ROBOTICS

28125

Manufacturer Part Number
28125
Description
TEXT ROBOTICS
Manufacturer
Parallax Inc
Datasheet

Specifications of 28125

Title
Robotics with the Boe-Bot
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
ACTIVITY #4: ARTIFICIAL INTELLIGENCE AND DECIDING WHEN
YOU’RE STUCK
You may have noticed that the Boe-Bot gets stuck in corners. As the Boe-Bot enters the
corner, its whisker touches the wall on the left, so it turns right. When the Boe-Bot
moves forward again, its right whisker bumps the wall on the right, so it turns left. Then
it turns and bumps the left wall again, and the right wall again, and so on, until somebody
rescues it from its predicament.
Programming to Escape Corners
RoamingWithWhiskers.bs2 can be modified to detect this problem and act upon it. The
trick is to count the number of times that alternate whiskers are contacted. One important
thing about this trick is that the program has to remember what state each whisker was in
during the previous contact. It has to compare that to the whisker states of the current
contact. If they are opposite, then add one to the counter. If the counter goes over a
threshold that you (the programmer) have determined, then, it’s time to do a U-turn and
reset that alternate whisker counter.
This next program also relies on the fact that you can “nest”
other words, the program checks for one condition, and if that condition is true, it checks
for another condition within the first condition.
it can be used.
ELSEIF (IN7
ELSE
ENDIF
Modify the
Bot broadcast its maneuver using the LED indicators.
IF condition1 THEN
GOSUB Turn_Right
HIGH 1
GOSUB Back_Up
GOSUB Turn_Left
LOW 10
LOW 1
GOSUB Forward_Pulse
Commands for condition1
IF condition2 THEN
IF…THEN
= 0) THEN
statement in RoamingWithWhiskers.bs2 to make the Boe-
Here is a pseudo code example of how
IF…THEN
statements. In

Related parts for 28125