Page 25 - The Definitive Guide to Building Java Robots
P. 25
Preston_5564C01.fm Page 6 Friday, September 16, 2005 6:36 AM
6 CHAPTER 1 ■ A PRIMER
I thought that moving to the refrigerator would not be that difficult, but as I started to
compile a list of tasks, then subtasks, and then detailed steps, I realized that I had better start
by organizing my thoughts around what I wanted to program (see Figure 1-6). How I organized
them (my thoughts) requires a little explanation, so here’s the definition of those terms:
• Events: These are the things that cause a robot to do something. Does it hear a word, see
something, or get a request from the network, or is there a scheduled task, or something
like that.
• Tasks: These are the things that events trigger. So if the robot gets a request to move
someplace, the top level task would be to move. The move task would then have to call a
subtask or another task to help.
• Subtasks: These are the things that help the task. So, if the task is to move from position A to
position B, a robot must know what direction it’s facing or consequently turn and face
that direction. Subtasks may call other subtasks or send or receive data packets from the
robot’s subsystems.
• Data packets: These are the final level of granularity in our task organization. A data
packet sends information to a controller to command the robot’s motor controls, or
sensors, whose sole purpose is to get and receive data from the robot’s subsystems or
peripherals.
Figure 1-6. A behavioral model of events, tasks, subtasks, and data packets