Datasheet

Page 176· Applied Robotics with the SumoBot
Your Turn - Drawing a State Machine Diagram
Try drawing a hybrid state machine diagram for the Main Routine in
FrontAndSideIrNavigation.bs2 from this chapter's Activity #3.
ACTIVITY #5: SEARCH PATTERN AND TAWARA AVOIDANCE
Before your SumoBot will be ready for a match, it's got to be able to stay inside that
white tawara line. When it doesn't see anything with its IR object detectors, it's also got
to have a search pattern that's more effective than sitting in one spot and waiting.
Especially for matches that start the SumoBots facing away from each other, an effective
search technique can make a huge difference in your SumoBot's likelihood of winning
each round. While this activity demonstrates one of many search patterns you can use, it
will be up to you to develop an optimal search pattern for your SumoBot.
Another State Machine Main Routine
The example program in this activity is the QTI version of the programs from this
Chapter's Activity #2 and Activity #3. Those programs combined the IR detection pin
definitions, constants, variables, and subroutines developed in Chapter 3 with the
navigation routines from Activity #1 in this chapter. The example program in this
activity combines the QTI line sensor program elements that were developed in chapter 3,
again with the navigation program elements developed in this chapter.
You've seen all the
PIN and DATA directives, constant and variable declarations and
subroutines before. The only thing that's really new is the Main Routine below, and even
that follows the techniques similar to the ones introduced in this chapter's Activity #2 and
#3.
Notice that the code blocks that handle the QTI detections (
IF qtiLF..., ELSIF
qtiRF...
) do not have any sensor conditions for exiting the loops. While it makes
absolutely sure that the SumoBot doesn't accidentally exit the ring chasing after a
spectator who's too close, it also prevents the SumoBot from decisively finishing off its
opponent in some cases. More about this double-edged sword on the Your Turn section.