Page 233 - The Ultimate Palm Robot
P. 233
Color profile: Generic CMYK printer profile
Composite Default screen
Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 8
216 The Ultimate Palm Robot
How Reflexes Work
In a word: pretty darn simply. Okay, that’s really three words. Not two. Not
four. Three. No more. No less. Three being the number of words and the num-
ber of words being three.
Reflex mode uses messages and reflex vectors. Amessage is a specific piece of
code stored on the BrainStem controller. This message consists of a BrainStem
command and the parameters needed by the command. Areflex vector is simply
alistof“pointers”tomessages.Whenareflexistriggeredinresponsetoaninput,
the messages in the reflex vector are executed. Among the numerous actions that
messages can perform are reading sensors, commanding servos, and calling
other reflexes.
Both the messages and the reflex vectors are compiled and downloaded to
the BrainStem using the Console application we looked at in the previous
section. After the messages and reflex vectors are downloaded to the
BrainStem, they will execute in response to specific stimuli.
A Simple Reflex Program
In this section, we’ll construct a very simple reflex program, and show you how
tocompileanddownloaditusingtheConsoleapplication.Programmingareflex
requires you to think a little differently. With TEA, C, and BASIC, one tends
to think linearly: the program starts here and proceeds through a series of
commands. With C++ and Java, one should be thinking in objects: the program
consists of components that cooperate by sending messages (method calls) to
each other. But in Reflex mode, you need to think about stimuli and responses.
There is not a controlling main( ) method to coordinate actions. If a stimulus
occurs, a reflex may or may not be activated. Stimuli can occur in any order with
nobeginningorend.Oncearesponseiscomplete,thereflexstopsexecutinguntil
it receives another stimulus. As we mentioned above, messages can cause other
reflexes to execute, so it is possible to create stimulus-response cycles with
messages and reflex vectors.
Let’s do something simple. We’ll have the robot simply move back and
forth continuously. So what are the commands we need?
❏ Command servos to move forward
❏ Countdown two seconds
❏ Command servos to reverse
P:\010Comp\Bots\880-6\ch08.vp
Monday, May 12, 2003 1:16:46 PM