Convex MPC   Whole-Body Control   2026

BHEEMA
Making a humanoid
walk from scratch

A convex MPC locomotion controller for the Unitree G1 humanoid, built entirely from scratch in MuJoCo. Single rigid-body dynamics, Pinocchio whole-body control, and OSQP solving the QP in under 2 ms.

1.4ms
MPC solve
16 Hz
MPC rate
200 Hz
WBC rate
20s+
Stable walk
Walking demo
Unitree G1 bipedal walking   MuJoCo   Convex MPC + Whole-Body Control
What this is

Convex MPC for
bipedal locomotion
on the Unitree G1

BHEEMA is a model predictive control based locomotion system for the Unitree G1 humanoid. I built the entire control stack from the ground up, following the MIT Cheetah 3 convex MPC framework and adapting it for a bipedal platform with passive ankles.

The G1 has no actuated ankles, which changes everything. Most bipedal MPC formulations assume 12 degrees of force control per step. The G1 only gives you 6 since each foot is effectively a point contact. The entire MPC had to be built around that constraint.

The system runs entirely in MuJoCo with hardware-matched actuator limits. The MPC plans at 16 Hz, the whole-body controller executes at 200 Hz, and the physics runs at 2000 Hz. The robot stands indefinitely and walks forward with an alternating gait for over 20 seconds.

Architecture

Three rates.
One control loop.
Full stack integration.

The MPC solves a convex QP over a finite horizon using single rigid-body dynamics. It outputs optimal contact forces for each stance leg. Those forces get mapped to joint torques by the whole-body controller through Jacobian transposes, then combined with gravity compensation and joint-level PD feedback.

The swing leg controller uses 6D operational-space impedance control to track foot trajectories generated by a Raibert heuristic footstep planner. The gait scheduler coordinates which legs are in stance and which are in swing at any given moment.

16Hz
Centroidal MPC
SRBD dynamics, OSQP solver, friction cones, contact force output per stance leg
OSQP
↓   contact forces
200Hz
Whole-Body Controller
Stance: J^T force mapping + gravity comp + PD. Swing: impedance control
Pinocchio
↓   joint torques
2000Hz
MuJoCo Physics
Full rigid-body simulation, hardware-matched actuator limits (88/139/50 Nm)
MuJoCo
MPC Formulation

Single rigid-body
dynamics

The centroidal MPC models the G1 as a single rigid body with external contact forces acting at the feet. The rotation dynamics are linearized around the current orientation to keep the optimization convex, which means the QP solves fast and reliably every cycle.

Friction cone constraints are approximated as pyramids and enforced directly in the QP. The cost function penalizes deviations from the desired body pose and velocity, with pitch and roll weighted highest to keep the linearization valid.

  • Single rigid-body dynamics with linearized rotation
  • 6D contact force formulation for passive ankles
  • OSQP as QP solver with warm starting
  • Friction cone constraints as linearized pyramids
  • Pitch/roll weighted highest in Q matrix for linearization validity
  • Horizontal force bounds at 400N per stance leg
  • 1.4 ms average solve time, well within 62.5 ms budget
  • Raibert heuristic footstep planner with gait scheduler
Whole-Body Control

From contact forces
to joint torques

The MPC outputs desired contact forces. The whole-body controller's job is to turn those into actual motor commands that keep the robot balanced. Here is exactly how that happens at 200 Hz.

01
Jacobian-Transpose Force Mapping
The MPC contact forces are mapped to joint torques through the foot Jacobian transpose. This is the primary torque signal for stance legs.
Pinocchio   J^T
02
Gravity Compensation
The full Coriolis and gravity vector from Pinocchio is added to the feedforward torques. Without this, every joint has to fight gravity purely through the MPC force signal.
C(q,dq) + g(q)
03
Joint PD Feedback
A proportional-derivative feedback layer (Kp=175, Kd=20) runs on top of the feedforward torques. This is what keeps the system stable under perturbations that pure feedforward cannot handle.
Kp=175   Kd=20
04
Swing Leg Impedance Control
Swing legs track foot trajectories using 6D operational-space impedance control. The foot path is generated by the Raibert planner and the controller handles the tracking.
6D Impedance
System

Every component
accounted for

MPC Solver
OSQP
Convex QP for centroidal dynamics. Sparse formulation, warm-started between solves, 1.4 ms average.
Dynamics
Pinocchio
Analytical Jacobians, gravity vectors, forward kinematics, center of mass computations. Runs at 200 Hz.
Simulator
MuJoCo
Full rigid-body physics at 2000 Hz. Hardware-matched actuator limits: hip 88 Nm, knee 139 Nm, ankle 50 Nm.
Stance Control
J^T + Gravity + PD
Feedforward force mapping plus gravity compensation plus joint-space PD feedback for disturbance rejection.
Swing Control
6D Impedance
Operational-space impedance controller tracking foot trajectories from the Raibert footstep planner.
Footstep Plan
Raibert Heuristic
Velocity-based footstep placement with gait scheduler coordinating stance and swing phase timing.
Robot
Unitree G1
29-DoF humanoid with passive ankles. Point contact feet. MJCF model with hardware-matched actuator specs.
Reference
MIT Cheetah 3
Convex MPC for legged robots. Adapted from quadruped to bipedal with passive-ankle 6D force formulation.