The experiment loop
Evaluating humanoid push recovery in MuJoCo
Record MuJoCo policy rollouts with Rerun, and find out why the robot falls.
A walking humanoid kept falling when pushed from behind, and we wanted to know why. We saved every episode as a Rerun recording, and used those recordings to find the pattern in the falls, replay them, and test our explanation on more policies.
What we found
A Unitree G1 humanoid walks forward at 1 m/s in MuJoCo, driven by a policy trained with mjlab. At a random moment in every episode we push it with 200 N for 0.2 seconds. An episode succeeds if the robot is still on its feet 8 seconds later.
The baseline policy survives 75% of the pushes. Split by push direction, it falls every time it is pushed from behind or diagonally from behind, and never when pushed from the side or the front:
| Policy | Overall | 0° | 45° | 90° | 135° | 180° | 225° | 270° | 315° |
|---|---|---|---|---|---|---|---|---|---|
baseline | 0.75 | 0.0 | 0.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 |
stronger_kicks | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 |
faster_commands | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 |
both | 0.94 | 0.5 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 |
The direction is relative to the robot: 0° pushes it the way it walks, and 90° pushes it to its left. Each cell is the success rate of 2 episodes.
Replaying the falls shows why: the push speeds the robot up from 1 m/s to about 3 m/s, and during training the baseline was never commanded to go faster than 1 m/s. It keeps taking walking steps while its body gets ahead of its feet.
During training, mjlab kicks the robot at random moments: a sudden change to its velocity of up to 0.5 m/s. That is not the same as the push in our evaluation, which is a force held for 0.2 seconds. To test the explanation we trained three more policies, changing the commanded speed, the kicks, or both:
stronger_kicksis kicked twice as hard: up to 1 m/s.faster_commandsgets the baseline's kicks, but is commanded to walk at up to 3 m/s.bothgets both changes.
faster_commands was never kicked harder during training than the baseline, and it recovers from every push.
The push also speeds it up to about 3 m/s, but it keeps its feet under it and slows back down to a walk within about a second and a half.
Combining the two changes seems to do worse than either one alone: both is the only one of the new policies that still falls when pushed straight from behind.
How we did it
Recording each episode
Each episode is one Rerun recording, saved as its own .rrd file.
Rerun's MJCF importer logs models/scene.xml, the file MuJoCo simulates, so the Viewer shows the simulated robot with its meshes, joints, and frames.
The importer also turns MuJoCo's joint positions into transforms, so the motion is logged straight from qpos, without writing any forward kinematics.
The meshes are most of the data, and they are the same in every episode. So we save the model once, in a recording of its own, and register it as an asset of the dataset. The Viewer loads it along with every episode it opens, and each episode only holds what changes.
Next to the motion we log the signals that explain a fall: the commanded and measured forward velocity, how upright the pelvis is, the policy's actions, and the push as an arrow at the torso, where it is applied.
The policy, the push, and the outcome go into the episode's recording properties. The success rate is then computed from the recordings you replay, instead of from a separate results file.
From the recordings to the table
We load the folder of .rrd files as a dataset in a local catalog server.
Every episode becomes a segment of the dataset, which is one row of the segment table, with its properties as columns.
The table at the top of this page is one group-by over those rows, with a filtered average per push direction:
success = col("success").cast(float)
summary = episodes.aggregate(
[col("policy")],
[
F.avg(success).alias("overall"),
*[
F.avg(success, filter=col("push_direction") == lit(direction)).alias(f"{direction:.0f}°")
for direction in directions
],
],
)From the table to the falls
An episode's seed sets the moment of the push, so for a given seed every policy gets an identical push.
Filtering the segment table on success gives the falls.
Joining them with the successful episodes on force, direction, and seed pairs each fall with a policy that recovered from that push.
The example prints the rerun commands that open the first three pairs, and keeps serving the dataset until you stop it.
In the fall below, the push comes about 4 seconds in.
The forward velocity jumps from 1 m/s to almost 3 m/s, the policy's actions start to swing, and the robot is on the ground within half a second.
faster_commands also reaches about 3 m/s after that push, and slows back down to a walk.
Run the code
pip install -e examples/python/mujoco_policy_eval
python -m mujoco_policy_evalEvery .onnx file in models/policies is evaluated, so drop in your own mjlab-exported G1 policy to compare it.
With 2 episodes per cell the numbers are coarse, so evaluate more episodes before trusting a single cell.
The default run writes about 60 MB of recordings, and --seeds 10 about 240 MB.
python -m mujoco_policy_eval --seeds 10With 10 episodes per cell both succeeds in 60% of the pushes from straight behind, and the baseline starts to fall at 315° as well.
Pushing harder shows where the other policies start to fall:
python -m mujoco_policy_eval --push-forces 250 300To open the episodes of an earlier run, serve them again without new rollouts:
python -m mujoco_policy_eval --report-onlyGoing further
Here the dataset lives in a local server that is gone when the script ends. Register the recordings to a dataset on Rerun Hub, and every evaluation run stays queryable: you can compare each new policy against the earlier ones, and send a teammate a link to the exact episode where the robot fell.
The robot model and the policies come from mjlab, see models/README.md.