Activity #4: Artificial Intelligence And Deciding When You're Stuck - Parallax Boe-Bot Student Manual

Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

Page 182 · Robotics with the Boe-Bot
GOSUB Turn_Right
ELSEIF (IN7
HIGH 1
GOSUB Back_Up
GOSUB Turn_Left
ELSE
LOW 10
LOW 1
GOSUB Forward_Pulse
ENDIF
Modify the
IF...THEN
Bot broadcast its maneuver using the LED indicators.
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.
IF condition1 THEN
Commands for condition1
IF condition2 THEN
= 0) THEN
statement in RoamingWithWhiskers.bs2 to make the Boe-
statements. In
IF...THEN
Here is a pseudo code example of how

Advertisement

Table of Contents
loading

Table of Contents