# Unitree G1 biped training example This 29-joint humanoid uses the Unitree G1 model and STL meshes from the local [mjlab asset zoo](../../rl/mjlab/asset_zoo/robots/unitree_g1/xmls/g1.xml), introduced in commit `004afda1ac1dafc3aedd4e9ca8c6d2242b399f57`. The files come from MuJoCo Menagerie and are copyright 2016–2023 HangZhou YuShu TECHNOLOGY CO., LTD. (Unitree Robotics), under the [BSD 3-Clause License](../../licenses/mujoco_menagerie-unitree_g1.txt). The repository [NOTICE](../../NOTICE) and [provenance](model-provenance.json) identify the files and their hashes. `g1.xml` rebases mesh paths and applies the reflected motor armatures from the vendored [G1 constants](../../rl/mjlab/asset_zoo/robots/unitree_g1/g1_constants.py). The compiled masses, joint limits, mesh vertices and reference pose match the source exactly. The MJCF round trip changes collision geom sizes by at most 4.4e−8 m and quaternion components by at most 4.2e−7. Several articulated links carry visual meshes and inertia only. Each named ankle roll body carries seven collision capsules that represent its sole. ## Stance calibration `stance.json` specifies a symmetric, slightly bent stance with a 0.24 rad knee angle and −0.12 rad hip and ankle pitch. It uses the vendored effort limits. The calibration estimates each joint's apparent inertia as `1 / diagonal(inverse(M))`, using the full mass matrix `M` of the floating robot at that pose. This captures the inertia when other coordinates can move in response to the applied joint effort. Gains use 14 Hz, 28 Hz at the ankles and a damping ratio of 0.85. In the reference hold, the floating-base model with mass-matrix diagonal gains and the vendored home pose fell. The two-second native hold completed 1,000 steps. The peak base drift was 2.30 mm and the peak base rotation was 0.00410 rad. The soles supported 99.9998% of the robot's 327 N weight on average. The maximum joint tracking error was 0.0126 rad and peak effort was 12.6% of its configured limit. There were zero self contacts and zero MuJoCo warnings. `robot.json` specifies an action scale of 60% of effort limit divided by proportional gain per joint. Limb contacts carry a penalty. Pelvis, torso and head contacts terminate the episode. The generated [robot specification](../../tasks/g1_example/robot_spec.py) is the only training task file and uses the locked biped template. From the checkout root with the Python environment activated, use fresh output paths for the reports. The scaffold command writes a new robot specification when its destination is empty. ```bash python scripts/onboard.py inspect assets/g1_example/g1.xml \ --profile assets/g1_example/profile.json --report out/g1_example/intake.json python scripts/onboard.py calibrate --model assets/g1_example/g1.xml \ --config assets/g1_example/stance.json --report out/g1_example/calibration.json python scripts/onboard.py scaffold-tier3 --config assets/g1_example/robot.json \ --calibration out/g1_example/calibration.json --tasks-root out/g1_example/scaffold python scripts/train.py --task g1_example --backend native --device cpu \ --num-envs 4 --headless --no-tensorboard --max-iterations 1 ``` ## Warp constraint allocation A 1,024-environment run with the default Warp allocation aborted before completing its first update. It reported that the 64-row constraint buffer was too small during contacts. A 64-environment smoke also logged overflows. The model needs room for the constraints from its soles and contacts made during falls. The following run uses the vendored G1 flat configuration's 300-row allocation while leaving model contacts and template behavior as configured. Training saves the allocation for matching Warp replay. ```bash python scripts/train.py --task g1_example --backend warp --device cuda \ --num-envs 1024 --warp-max-constraints 300 --headless --no-tensorboard \ --max-iterations 1200 ``` ## Measured training and replay The first run completed 1,200 updates and 29,491,200 environment steps on an RTX 5080. Physics ran at 400 Hz and policy control at 50 Hz. The Warp allocation record reported 300 constraints per environment and 49,152 contacts shared across 1,024 environments. The replay used the saved command ranges and disabled observation noise. In a 12-second Warp replay with a +0.25 m/s held command, the first checkpoint averaged +0.0002 m/s with 0.250 m/s mean absolute error. Checkpoint 1199 averaged +0.218 m/s with 0.070 m/s mean absolute error. The same checkpoint averaged −0.185 m/s under a −0.25 m/s command with 0.066 m/s error. All seven held-command and idle replays had zero episode resets on both Warp and native MuJoCo. The lateral and yaw tests missed their targets. For example, Warp measured +0.007 m/s against +0.12 m/s lateral and +0.047 rad/s against +0.30 rad/s yaw. The exported native ONNX actor passed the physics stage and failed the tracking stage on the same seven commands. The held-command checks use forward and reverse at 0.25 m/s, left and right at 0.12 m/s, yaw in both directions at 0.30 rad/s, and idle. Each replay lasts 12 seconds. The ONNX acceptance requires a mean error and mean absolute error within 0.12 m/s forward, 0.06 m/s lateral and 0.15 rad/s yaw, along with native physics checks. For the Warp forward measurement, substitute the actual checkpoint path from the run. ```bash python scripts/play.py --task g1_example --checkpoint path/to/model_1199.pt \ --backend warp --device cuda --warp-max-constraints 300 \ --headless --steps 600 --speed 0 --measure --checkpoint-command-ranges \ --no-obs-noise --command 0.25 0 0 --evaluation-out out/g1_example/forward.json ``` A continuation from checkpoint 1199 initially widened the command range before collecting a complete fresh episode. The runner had randomized starting episode ages, so the restored curriculum clock admitted biased tracking evidence. That run was stopped and excluded. After the resume fix, training restarted from checkpoint 1199 and kept the saved curriculum level through the fresh 1,000-step window. The checkpoint 1800 forward preview shows a short shuffle. Native ONNX contact measurements between 2 and 12 seconds found both soles loaded in 65.8% of samples and one sole loaded in the remainder. Peak sole clearance was 5.7 mm. Loaded ground contact points slid at mean speeds of 0.111 and 0.127 m/s on the two soles. Both soles stayed loaded throughout lateral and yaw replay. These are simulator gait diagnostics. The corrected continuation added 1,600 updates for a total of 68,812,800 environment steps across both valid runs. Checkpoint 2798 stayed at curriculum level 0. In Warp it averaged +0.257 m/s forward and −0.210 m/s reverse, with 0.036 and 0.046 m/s mean absolute errors. All seven native and Warp replays completed with zero resets. The standalone lateral and yaw commands still missed their targets. Native ONNX replay passed physics and failed tracking acceptance. Mixed commands showed that the policy could control all three axes when the forward command was present. Under `[0.25, 0.12, 0.30]`, native replay averaged `[0.244, 0.107, 0.289]` in body-frame m/s, m/s and rad/s. Under `[0.25, -0.12, -0.30]`, it averaged `[0.290, -0.112, -0.303]`. Switching from forward motion to a side-only or yaw-only command brought the robot back to a planted stance. The example currently provides the calibrated model and training task. The ONNX export is retained as a diagnostic. A second continuation added 3,000 updates, bringing the total to 5,800 updates and 142,540,800 environment steps. The run stayed at curriculum level 0 and logged no Warp capacity overflows. Checkpoint 5797 returned these 12-second results on the training backend with observation noise turned off. | Command | Target | Mean | Mean absolute error | | --- | ---: | ---: | ---: | | Forward, m/s | +0.25 | +0.240 | 0.017 | | Reverse, m/s | −0.25 | −0.240 | 0.013 | | Left, m/s | +0.12 | +0.003 | 0.117 | | Right, m/s | −0.12 | −0.115 | 0.017 | | Yaw left, rad/s | +0.30 | +0.225 | 0.089 | | Yaw right, rad/s | −0.30 | −0.264 | 0.059 | All seven replays, including idle, completed without resets on both Warp and native MuJoCo. The native ONNX policy passed physics verification. It still failed the leftward command and exceeded the 0.15 rad/s yaw-error limit by 0.00025 rad/s during the forward probe. In the ONNX forward gait, peak sole clearance remained 5.5 mm. Loaded contact slip decreased to 0.057 and 0.089 m/s. Both soles remained loaded during the left command. This checkpoint is retained for diagnosis without a release app. The compliant-gain trial trained a fresh policy with the same mechanical model and softer hip and knee gains, but failed acceptance. Its task and source assets were removed; the failure record remains in [the refactor report](../../docs/REFACTOR_STATUS.md#g1-learning-and-selection). ## Verified checkpoint 7796 The last continuation added 2,000 updates. Across the four valid runs, the original-gain model completed 7,800 updates and 191,692,800 environment steps. The saved curriculum level was 0, which provides command ranges of ±0.28 m/s forward, ±0.14 m/s lateral and ±0.32 rad/s yaw. Checkpoint 7796 passed the original seven isolated-command probes in native ONNX replay. The table gives 12-second body-frame measurements for the commanded axis. The corresponding Warp and native checkpoint replays had zero resets, and the ONNX verifier recorded zero physics warnings. | Command | Target | Warp mean | Native ONNX mean | ONNX mean absolute error | | --- | ---: | ---: | ---: | ---: | | Forward, m/s | +0.25 | +0.259 | +0.258 | 0.020 | | Reverse, m/s | −0.25 | −0.241 | −0.242 | 0.015 | | Left, m/s | +0.12 | +0.105 | +0.105 | 0.028 | | Right, m/s | −0.12 | −0.152 | −0.152 | 0.034 | | Yaw left, rad/s | +0.30 | +0.217 | +0.215 | 0.108 | | Yaw right, rad/s | −0.30 | −0.296 | −0.297 | 0.068 | The idle ONNX replay held both soles loaded, with mean body-frame speeds of +0.00002 m/s forward, −0.0022 m/s lateral and +0.0046 rad/s yaw. In a separate test, each of W, S, A, D, J and L was held for 12 seconds, including the configured two-second ramp to its saved command limit. The highest per-axis mean absolute error across the six tests was 0.023 m/s forward, 0.037 m/s lateral and 0.102 rad/s yaw. Escape brought the robot back to idle in each test, with zero physics warnings. The final forward gait still used short, low steps. Both soles carried load in 51% of post-transient samples, and peak sole clearance was 5.7 mm. Left motion unloaded one sole in 49% of samples, with peak sole clearance 9.0 mm. These results describe simulated operation on the training plane.