several joints at once. Look at the code in Figure 4.
The first for loop prepares to walk by raising the
left leg and leaning the body forward. The second
loop continues raising the left leg while moving
the right leg backward (effectively moving the body
forward since the body is supported by the right foot).
Notice in Figure 4 how both arms are moved in a
natural motion while the other movements are occurring.
The humanoid ends up as shown in Figure 5 by the end
of the second loop.
The Robot Can Fall
figure can start straightening the left leg, or perhaps
bending the right leg. All of these actions will eventually
cause the right foot to reach the ground. Some of these
options could work better going up hill; others might be
preferred when going down a slope. One of the great
things about using a simulator is that you can easily play
with all the options and determine appropriate ways for
your robot to move without the possibility of damaging
anything if your programs do not work.
There is a third loop in Figure 4 that appears to do
nothing other than draw the robot. If you run the program
though, you will notice that once the robot reaches the
position shown in Figure 5, it will be off balance and
continued calls to the DrawRobot subroutine will cause it to
fall with the left foot as the pivot point. Once the right foot
hits the ground, it automatically becomes the new pivot
point and the robot will either be balanced or it will start
to fall around the right foot.
This is another compromise in the design of the
simulator. The most forward foot that is on the ground is
always considered as the balancing point for the figure (the
right foot is the default starting configuration). As long as
the robot is walking forward, this is not an unreasonable
compromise. If the robot starts to fall though, the
simulation makes no attempt to fall realistically which can
sometimes create an
awkward movement of
the limbs. The fall is
always apparent though,
so it is easy to see when
your program is not
keeping the robot
Once the robot has
reached the position
shown in Figure 5, it
needs to put its left
foot on the ground. If
it does nothing, it will
fall forward (which will
bring the foot to the
ground, but may create
a significant imbalance
because the body will
move forward too).
Programming the robot for autonomous walking is
harder than you might imagine. If you choose to make
the robot straighten its left leg, for example, you can’t just
tell it to straighten its left leg because you have no idea
where the ground is in relation to the foot. One solution is
to straighten the leg until the foot touches the ground
(or until it becomes fully extended). The code in Figure 6
shows one way of accomplishing this. Note: The
subroutine LtLegStraighten generates no action if the
leg is already straight.
Checking the value of the variable MainFoot is how the
programmer can determine when the left foot has reached
the ground. In addition to knowing which foot is the
balance point, the programmer needs to know if the robot
is falling forward or backward. This can be done in the
simulation by testing the variable Tilt to see which of the
following predefined constants it currently matches.
If the robot is falling backwards, the code fragment in
Figure 7 shows how you can direct it to try to regain its
balance. It is important to realize that there is no guarantee
that this code will work. The simulator has been designed
so that the robot’s movements are slightly faster than the
fall rate, but if the robot is significantly off balance, then it
may not be able to recover. Situations like this can be avoided
by not letting the robot get too far out of balance. This
can be done by having the program constantly monitor
the variable Tilt and make appropriate adjustments by
moving the robot’s body forward and backward during
the walking motion.
The code in Figure 4
produces this position.
Figure 6. This code continues until the
left foot touches the ground.
Maintaining proper balance while walking is not an
easy task. This is especially true because the robot may be
balanced when it steps off on the left foot but be totally
out of balance as soon as its weight is transferred to the
right foot (when the right foot becomes the new balance
point). The only way to prevent this is to maintain proper
body orientation during
all movements. Also,
even if you derive an
algorithm that works
on level ground, expect
failure when the robot
encounters a slope.
Learning how to
create an algorithm that
Figure 7. This code fragment tries to
keep the robot from falling backwards.
40 SERVO 11.2009