Bipedal Walker Simulation ReadMe

Introduction

The bipedal walker simulation code began as a few scripts, pieced together by Eric D.B. Wendel, in an attempt to understand how Arthur Kuo at the University of Michigan modeled a hipped bipedal walker.

A full-fledged simulation code developed over the course of the Fall 2005 semester in response to research goals. It must be emphasized that this code is the creation of the UC Berkeley CHESS Bipeds research group and is primarily a research tool.

The version of code provided on the CHESS Bipeds website, and referenced by this document, is deprecated as of February 17, 2006. Nevertheless, please contact us for any technical support issues that Google or Mathworks cannot resolve.

Functionality

The 2D bipedal walker is simulated by generating equations of motion in Mathematica, exporting them as C code, and then compiling the code for Matlab as a MEX file.

The equations are generated in Mathematica sometimes by hand, sometimes with the assistance of the Dynamics Workbench package created by Arthur Kuo at UMich.

Using Mathematica's built-in Splice command and the Format package created by Mark Sofroniou at Wolfram Research, we are able to export the equations as C code through a template containing expressions native to the Format package and are left with a C file.

Compiling the C file is straightforward using the Matlab MEX utilities, and we are left with a binary file which we can treat as a normal Matlab function. The extension of the binary file varies by platform, but the provided binaries were prepared on a PC platform so all of the MEX files are named "eqns2.dll" or "eqns3.dll".

The rest of this document is a primer for using the Matlab functions in the 2D directory to model the 2D walker.

The code uses use Matlab 7 R14 and Mathematica 5; no information on compatibility with other versions is available at this time.

General use

First, change into the directory holding the 2D code.

>> cd SomeDirectory\
>> cd 2D

The 2D or 3D directory holds all of the functions to simulate the walker, so it will always be your working directory. Now type "pop" in the Matlab Command Window.

This command creates several global variables necessary for the C Mex file to operate. If they are not defined then the simulation will error out. Type "opp" to conveniently clear out all Mex, global, local, and graphics objects so you can start afresh.

But wait: after you typed "pop" Matlab confronted you with a decision:

>> pop
Choose a model:

Point foot, midleg mass:
[1] Passive
[2] Controlled (PE shaping)

Roll foot, midleg mass, passive:
[3] Ang cons impacts (most likely)

Choosing 1, 2, or 3 will set the value of the global variable "modeldir" to the directory holding the corresponding model. Each of the directories corresponding to options 1, 2 and 3 are inside the 2D directory with names like "C:\SomeDirectory\2D\pointfoot-midlegmass". Just keep in mind that pop, when run for the first time, will make you choose a model.

Subsequent calls to "pop" will generate the global variables that constitute the walker parameters like slope, mass, leg length, etc, and a working point on the limit cycle as an initial condition.

...
Make a choice: 2
modeldir =
C:\SomeDirectory\2D/pointfoot-midlegmass/controlled/
M =
5
Mp =
10
g =
9.80000000000000
L =
1
dim =
5
slope =
0
alpha =
0.06283185307180
c =
8
mu =
0
xi =
-0.28840000000000 0.28840000000000 -1.60090000000000 -1.97620000000000 -0.20000000000000

And that's all you need to get started. Refer to the CHESS website for detailed instructions on using the simulation code, and also read the following section.

Available functions

Relevant functions will have documentation inside them. Important functions are listed below. Type "help (name of function)" to easily access docs from the Command Window.

In the "C:\SomeDirectory\2D" directory:

In the "C:\SomeDirectory\3D" directory:

The functions in the 3D directory are analogous to those in the 2D. Sometimes the documentation is more up-to-date in the 3D directory, so read those first.

Just a note, step?, walk?, and animate3 are the functions in both the 2D and 3D directories that simulate the walker for 1 step, an arbitrary number of steps, and animate the walker using Matlab graphics.

Editing the C files

This is a complicated process; you must have knowledge of C Mex programming, C programming, and have a general understanding of how the Mathematica equations are exported into C. For the latter, read through any of the .nb files in the model directories ("C:\SomeDirectory\2D\pointfoot-midlegmass\pointfoot-midlegmass-2D.nb").

In a nutshell, Mathematica reads the template named eqns?.mc in the model directory, parses the commands embedded inside the template, and generates a compilable file names eqns?.c. In the Matlab command window, type

>> edit([modeldir 'eqns2.c'])

to edit the .c or .mc file, and then when you are ready to compile, type

>> mex([modeldir 'eqns2.c'])

Of course, in order to compile you must have defined a suitable compiler (the default Matlab lcc compiler should do) using the "mex -setup" utility. Any compiler will do, as long as it supports numerical exceptions according to the ANSI standard; do not use the free Borland C++ compiler since it does not.

Additional notes

Type "pop" to choose a model and define model parameters. Important variables are "eqnhandle", "modeldir" and "invalidResults".

"eqnhandle" is a function handle to the eqns2.dll or eqns3.dll held inside "modeldir". The step? function references this function handle.

The guard condition varies per model. It is exported from the Mathematica files into the dll along with the dynamics.

The animation functions are a little out of date.