The objective of this assignment was to take a mech, model it as an articulated body, and then have it walk across uneven terrain, maintaining the correct joint angles in its legs and feet. The goal was to devise a system that would allow the Mech to automatically calculate the proper motions, as the terrain would be randomly generated.
Here you can see the entire window. The controls are fairly self-explanatory. Viewing controls and lighting are at the lower left, with animation speed at the very corner. To the right of the viewing controls, the camera's focus can be placed on either the Mech or the terrain, and the camera's panning can be locked to the direction that the mech is facing.
Below the camera settings are two buttons that can run or halt the simulation. When the program is first loaded, the simulation is paused, so you must press on the [Run Simulation] button to begin. You can press the [Halt Simulation] to pause it.
Terrain generation controls allow the user to generate random terrain. The desired number of passes over the terrain describes how differentiated the terrain will be, as it initially starts out all flat. The lower the number of passes, the more level the terrain will be. Select the number of passes desired using the slider, and then press the button to regenerate the terrain.
Along the right side are controls for the Mech itself. The user controls mech movement by specifying a speed and a steering. You can walk forwards or backwards and steer left or right, and produce any combination of velocity and steering. The program will then calculate how the mech should take a step and proceed from there. If you want the mech to come to a complete stop, you can hit the [Halt] button.
Below the locomotion controls are Mech posture controls. These allow the articulation of the upper body to be put to use, so you can pose the torso and arms. At present, the Mech can't fire its weapons, but if that should ever be implemented, the system is already in place to allow the user to aim the weapons mounted on the arms and on the shoulder.
The [Save PPM] button can be used to take screen captures of the OpenGL window.
Finally, when you've had enough, you can hit the [Exit] button and quit.
The first step was in being able to generate some random terrain. This was not overly difficult, and was achieved by initializing the height of all points on the terrain to zero. After that, a random number of these points would be seeded with slight elevation increases, and hills would grow from there.
Once that was done, a mech was modelled, with a data structure to hold information on each limb's joint angles and translations. This was basic articulated body modelling.
Before I could get the mech to walk, I
needed to make sure it could stand still on the terrain properly.
This was accomplished by finding the x and y coordinates
of the hip, and then extrapolating from there to find the x/y coordinates
of the feet. The terrain height was then interpolated from the surrounding
terrain polygon vertices, and the leg at a lower height would be straight,
while the other one would be bent to conform to the terrain. The
feet were oriented to match the ground by accessing the normal vector of
the terrain polygon. The result was this:
The next step was to be able to take in
a user-specified velocity and steering, and compute where the step should
fall. Differences in height between starting and ending points of
a step cycle were accounted for. As a debugging tool, I drew spheres
where it was calculated that the various parts should end up:
After that, it was a matter of interpolating
between start and end points. I didn't want a linear interpolation,
as that would have the mech dragging its feet across the ground, rather
than stepping up and over. I ended up generating a walk cycle using
sin functions, and adding a height offset to the linear motion.
The hips, it was reasoned, would drop slightly in height, while each foot
should be moving above the ground. Once these calculations were done,
spheres were animated, following the path that the hips and feet would've
followed, again as a debugging tool:
Finally, it was just a matter of moving
the hips along and calculating the correct joint angles for the feet.
The first attempt at this was not wholly successful, but produced a funny
looking animation:
Once this was corrected for, however, I
got the result I had intended:
Here you can see some video clips of the
output:
Video Clip #1
Video Clip #2
And one last glory shot of my mech imperonating
Neo's bullet-dodging =P
{=== End of Report ===}
Questions, criticism, and comments can be directed to: phalanx@cats.ucsc.edu