Convex MPC controller for a Mini Cheetah quadruped in Drake, reimplementing Dynamic Locomotion in the MIT Cheetah 3 Through Convex Model-Predictive Control. Originally a UPenn MEAM 5170 course project.
uv venv --python 3.12 && source .venv/bin/activate
uv pip install drake numpy pydot matplotlib pytest
python simulate.py --mode 0 # standing
python simulate.py --mode 2 # single-leg raise
python simulate.py --mode 3 # trot in place
python simulate.py --mode 3 --vx 0.3 # walk forward
python -m pytest # run the testsOpen the printed Meshcat URL in your browser. Add --show-reference / --show-contacts
to overlay the reference ghost geometry or contact-force arrows.
The original version could stand but not walk. Working through it with Claude fixed the core issues, verified incrementally with unit + simulation tests:
- MPC model corrected to match the paper — moment arms about the true COM, whole-robot inertia about the COM (was ~7× too small), yaw-only rotation, and robot-only mass (the ground link was being counted).
- Speed & determinism — solve the MPC once per tick with matrix-form constraints; plan/torque state moved out of Drake output ports.
- Velocity-commanded reference — the body reference is integrated from a commanded twist and re-anchored to the robot each solve (instead of hand-set foot positions).
- Footstep planning — corrected Raibert heuristic and a foothold schedule fed into the MPC over the horizon; stance legs hold via gravity/Coriolis compensation.
- Fixed a left/right mass asymmetry in the URDF.
