Introduction The Alpha Rex
Probably the most complex of the RoboCenter series of robots, both from the mechanical
design perspective and the software programming perspective.
The following discussion will concentrate on software programming of the Alpha Rex.
The program described below illustrates two advanced programming
techniques: state machines and abstraction.
A state machine design handles basic movements
such as tilting side to side and
striding the robot’s feet forward and backward.
Abstraction handles combining the basic movements into more complex movements,
such as walking forward and turning right and left.
The inspiration for this program comes mainly from sources other than the
NXT lego Mindstorms
RoboCenter software examples for the Alpha Rex.
The RoboCenter examples perform basic movements such as walking forward and turning.
However the examples are rather inadequate when it comes to combining basic movements
into more complex movements, such as having your Alpha Rex move in a figure eight pattern.
Furthermore, including such functionality as having the Alpha Rex walk around avoiding
obstacles behooves the application of more advanced programming techniques.
The following sections describe these techniques in much more detail.
The final section, following the description of these techniques, presents the development
of a complete program for avoiding obstacles.
Abstraction In short, abstraction in software design means designing software according to
a hierarchal approach that begins with basic building blocks and ends with
complex programs built from basic building blocks.
For example, the Alpha Rex program begins with basic building blocks for tilting the
robot side to side, and moving the robot’s feet forward and backward.
The second level of abstraction combines these basic building blocks into routines that
perform such movements as: walking forward, walking backward, turning right, and turning left.
The third level of abstraction uses these building blocks to do something practical, such as have
the Alpha Rex walk in squares, or move about avoiding obstacles.
Microsoft Windows provides a classical example of abstraction.
At the lowest level of Windows we find the Microsoft Hardware Abstraction Layer (or HAL).
The HAL contains all the drivers that actually operate all the hardware in your
computer: memory, disk drives, USB ports, keyboard, monitor, etc.
(Use the Windows Device Manager to see all the hardware drivers in your PC.)
The Alpha Rex mechanical design falls into a category referred to by robotics hobbyists as a toddler biped.
Generally speaking a toddler robot uses only two servos for movement, like the Alpha Rex.
One servo shifts the robot’s weight from one foot to the other foot.
The other servo moves the feet backward and forward.
Efficiency and economy in programming dictates that these basic movements link together
seamlessly to provide more complex movements, such as walking forward, or turning right.
Seamless movement, from a programming perspective, requires that movements do no
t depend on other movements. Seamless movement means that a composite movement,
such as tilting left and moving the right foot forward, may be combined together without the
programmer needing to concern themselves with the
details of servo position, direction of rotation, and amount of rotation.
The composite movement routines, described below, make use of two basic building
blocks: a routine for tilting the robot side to side, and a routine to move the robot’s feet back and forth.
In the case of the Alpha Rex the components are the robot’s two legs, which have two
degrees of freedom in the way they can move: shifting the weight of the robot from one leg to the other,
and moving one leg forward at the same time moving the other leg backward.
The rotation sensors built into the NXT motors allow them to work very nicely as servo motors.
