Page 29 - The Definitive Guide to Building Java Robots
P. 29
Preston_5564C01.fm Page 10 Friday, September 16, 2005 6:36 AM
10 CHAPTER 1 ■ A PRIMER
Figure 1-7. A simple state machine
So when you have a set of subtasks that you need to perform to get your robot to move, you
should have a state diagram that transitions your robot from one state or subtask to another
state or subtask.
However, doing this programmatically in Java with robots is a bit harder than dealing with
the theory or picture just discussed, but the idea of a state machine does help in organizing
what you want your robot to do, how you want your robot to do it, and most importantly: when
you want your robot to do it. Finally, in order for your program to transition properly, when it’s
ready you’ll need to be able to “pause” your program to allow these new states to materialize.
To pause your program with Java, use the following four ways defined in Table 1-3.
97022d2480fe4a63cfdfa123a6e70098