← Open Source

Terrain Grounded Imagination: a recipe for training legged robot locomotion on sparse, rough, and 3D terrain through a world model with differentiable terrain lookups.

Python
Momentum
+6stars in 24 hours+1.9%
320
Stars
17
Forks
2
Contributors
Created 2026-11-03 · Updated 2026-12-06 · #2062 today
Top developers
mheyrmanqwwwfs
README

Terrain-Grounded Imagination

Paper: Terrain-Grounded Imagination: A Recipe for Training Perceptive Legged Locomotion through a World Model

2.5D TGI: Unitree G1 3D TGI: ANYmal-D

Terrain-grounded imagination (TGI) trains legged locomotion policies entirely inside a learned world model. This repository contains 2.5D TGI for the Unitree G1, 3D TGI for the Unitree G1 and 3D TGI for ANYmal-D.

How it works

  • World model. Fit to simulator transitions, it predicts the robot's next state and its contact forces from the current state, the action and the terrain around the robot.
  • Terrain from the simulator. The terrain is not learned: the world model, rewards, terminations, critic and perception read it from the simulator through differentiable lookups, so edges and gaps stay exact in imagination.
  • Training in imagination. From simulator states, the policy rolls the world model out for 32 steps (0.64 s) and is updated by backpropagating the return through the model and the lookups, with a critic after the last step.
  • Gradient cut. At imagined touchdowns on poorly supported terrain the backpropagated gradient is unreliable, so the return is cut there and the critic takes over.
  • Perception. The recipe is not tied to one perception model: any perception that reads the terrain through the lookups works the same in the simulator and in imagination. We show two: foothold perception from Watch Your Step, where a foothold prediction model (FPM) predicts the next footholds and the policy sees the terrain only around them, and a voxel-based visual perception from an egocentric LiDAR scan.
  • Impact penalty. Imagined contact forces above a threshold are penalized, so the policy learns to avoid hard impacts before they happen.
  • Curriculum. A success-guided sampler picks the terrain types and difficulties.

Installation

Tested on Linux with Isaac Lab 3.0.0 (Isaac Sim 6.1, Newton 1.6.1, PyTorch 2.11). Install Isaac Lab 3.0, then, in its Python environment:

git clone https://github.com/leggedrobotics/terrain-grounded-imagination
cd terrain-grounded-imagination
pip install -e fpm --no-deps
pip install -e tgi
pip install -e tgi_g1_3d
pip install -e tgi_anymal

fpm/ holds the G1 environments and the FPM of foothold-prediction-model, tgi/ the 2.5D G1 training, tgi_g1_3d/ the 3D G1 training and tgi_anymal/ the 3D ANYmal-D training.

2.5D TGI with Unitree G1

  • Environment. The fpm G1 environment on Newton physics: velocity commands over stairs, gaps, pits and stepping stones.
  • Terrain input. The heightmap under the pelvis and the soles.
  • Contacts. The world model predicts the sole forces; forces above 450 N are penalized.
Obstacle course (MuJoCo, sim-to-sim) Dynamic Terrains (MuJoCo, sim-to-sim)
Stairs (hardware) Mattresses (hardware)

Training

The defaults train the recipe: 8192 environments for 40k iterations, about 7.5 h on an RTX PRO 6000. From tgi/:

python scripts/convert_g1_usd.py   # once
python scripts/train.py --log_dir logs/<run_name>

Export and evaluation

python scripts/export.py --ckpt logs/<run_name>/ckpt_040000.pt
python scripts/sim2sim.py --export_dir logs/<run_name>/export_040000 --terrains stairs:0.20 fpmstones:0.6 pit:0.30
bash scripts/isaac_eval.sh logs/<run_name>/export_040000/model_40000.pt 520 cuda:0

The export is in the fpm format, so python scripts/play.py --checkpoint <export dir>/model_40000.pt plays it from fpm/. sim2sim.py runs it in MuJoCo with Unitree's G1 model, and isaac_eval.sh runs the fpm locomotion validation.

isaac_eval.sh is a quick check (1100 steps, startup randomization on). The paper's locomotion test uses the full protocol: from fpm/, python scripts/validate_locomotion.py --checkpoint <model.pt> --num_envs 520 --num_steps 3300 --save_results with the startup randomization zeroed (env.events.base_com.params.com_range.{x,y,z}=[0.0,0.0] env.events.default_joint_pos_offset.params.position_range=[0.0,0.0]). It covers 13 terrain types, five of them held out from training, in about 2990 episodes. --save_results stores, per episode, the distance covered along the command as a share of the commanded distance and whether the robot fell. In the paper an episode is a success if the robot does not fall and covers at least 70 % of its commanded distance; the script's own printed "success" is the mean distance share.

Results of the paper (Table II): the recipe's policy at 40k iterations and PPO in the same setup, in % (mean ± standard deviation over five seeds), tested with Newton, which is used for training, and with PhysX for sim-to-sim transfer. Sparse: stepping stones, pallets and concentric gaps.

Simulator Test TGI success TGI falls PPO success PPO falls
Newton Locomotion 91.8 ± 1.2 1.0 ± 0.2 84.9 ± 2.0 0.6 ± 0.0
Newton Held out 90.9 ± 1.3 1.5 ± 0.4 83.4 ± 2.2 1.0 ± 0.1
Newton Sparse 55.7 ± 1.4 20.3 ± 1.3 48.2 ± 2.6 15.1 ± 0.9
PhysX Locomotion 86.5 ± 2.2 1.0 ± 0.2 85.1 ± 2.3 0.8 ± 0.1
PhysX Held out 86.7 ± 2.6 1.5 ± 0.2 83.0 ± 2.2 1.4 ± 0.3
PhysX Sparse 54.8 ± 1.8 18.6 ± 0.8 48.5 ± 1.8 15.2 ± 1.3

3D TGI with Unitree G1

The recipe's policy at 40k iterations in the training simulator. Low bar, low ceiling and rough terrain: the hardest training levels. Gaps: three 35 cm gaps, the widest of training, between a start and an end platform, with the goal on the end platform 3.5 m away (training goals: 2.9 to 3.3 m). Teal: the voxels of its LiDAR scan (drawn without the sensor noise, dropout and up to 100 ms delay the policy gets).

  • Environment. The fpm G1 environment on Newton physics, with a goal position instead of a velocity command: walk to goals over rough ground, stepping stones and gaps up to 35 cm wide, and duck under low bars, low ceilings and ledges with down to 1.0 m of clearance (the standing G1 is 1.31 m tall).
  • Terrain input in 3D. The policy sees a 32 x 32 x 40 voxel grid at 5 cm from two torso LiDARs, ray-cast from the robot's state, so it is computed the same way in the simulator and in imagination. The world model, rewards and terminations read one 3D distance field of the terrain, with a fine layer for the ground and a coarse layer for the overhangs:
    • Support. At 15 points on each sole: the distance and surface normal. A point is supported when it is within 3 cm of a surface that faces up, so stone edges and gaps are exact.
    • Collision points. At 53 spheres on the legs, pelvis, torso, head and arms: the distance and normal to the nearest surface, the ground included. The ankle braces may touch the terrain, the shins and thighs are penalized near it, and any other body part ends the episode when it touches.
  • Goal command. Each episode starts in the middle of an 8 m tile, with a goal near the tile's edge, 2.9 to 3.3 m from its centre, so the robot has to cross the tile's stones, gaps or overhangs. The policy sees the goal in its heading frame and the time left to reach it. A goal counts as reached after standing within 0.3 m of it for 1 s; then the next goal is drawn. The reward is the progress toward the goal at up to 0.6 m/s, then standing still once there.

Training

The defaults train the recipe: 4096 environments for 40k iterations, 12.1 h on an RTX 5080 (16 GB). From tgi_g1_3d/:

python scripts/convert_g1_usd.py   # once
python scripts/train.py --log_dir logs/<run_name>

Evaluation

python scripts/eval.py --ckpt logs/<run_name>/ckpt_040000.pt

reports the success rate, falls, contact terminations and ducking per terrain type and level. An episode succeeds when the robot survives its 20 s and reaches its first goal in the time allotted.

With 1,024 environments over the 10 terrain levels and no pushes (2,048 episodes), the recipe's policy at 40k iterations succeeds in 99.7 % of the episodes and falls in 0.15 %:

Terrain Episodes Success
Rough 306 99.7 %
Flat 135 100 %
Stepping stones 358 99.7 %
Stepping stones, level tops 367 100 %
Gaps 400 99.5 %
Low bar 174 99.4 %
Low ceiling 156 100 %
Ledge 152 98.7 %

On the three overhang terrains no episode ends in a fall, 0.6 % end with a body part in contact, and the robot ducks under the overhang in every episode.

3D TGI with ANYmal-D

  • Environment. Isaac Lab's ANYmal-D rough-terrain task on Newton physics: reach a goal within 8 s over climbs, gaps, pits, boxes, stairs and stepping stones.
  • Terrain input in 3D. The distance and direction from each foot and from spheres on the knees, shanks, thighs and body to the nearest surface, including walls.
  • Contacts on every body part. The world model predicts the contact force on each foot and body part, such as a knee pressing on a wall during a climb or the impact of a landing; foot forces above 600 N are penalized.


One continuous run in MuJoCo (sim-to-sim): climb up 0.85 m, stepping stones, stairs down, a 0.8 m gap, stairs up, climb down

Training

The defaults train the recipe: 4096 environments for 30k iterations, about 5.6 h on an RTX PRO 6000. From tgi_anymal/:

python scripts/train.py --log_dir logs/<run_name>

Evaluation

python scripts/anymal_term_level.py logs/<run_name>/ckpt_030000.pt

reports the success rate and how episodes ended, per terrain type and level. An episode succeeds when the robot ends its 8 s within 0.5 m of the goal.

With 2048 environments for 2000 steps over the 10 terrain levels (10,270 episodes), the recipe's policy at 30k iterations reaches the goal in 92.4 % of the episodes, and 5.6 % end with a base contact (91.0 ± 2.1 % success over five seeds):

Terrain Episodes Success
Flat 232 100 %
Rough 445 99.6 %
Slopes 414 100 %
Slopes, inverted 435 99.8 %
Stairs down 633 98.0 %
Stairs up 820 95.7 %
Boxes 860 97.7 %
Stepping stones 1864 82.1 %
Pit 425 93.9 %
Pit with a step 382 99.5 %
Climb up 1261 78.1 %
Climb down 1207 99.1 %
Gap 1292 95.1 %

Previous Work

TGI builds on:

  • SuperMimic: the training scheme, in which a world model is fit to simulator transitions and the policy is trained by backpropagating the return through short imagined rollouts.
  • Watch Your Step: the foothold-gated perception, the G1 locomotion environments and the validation suites.
  • SHAC: the policy objective, a short-horizon return backpropagated through time and bootstrapped with a critic.
  • Robotic World Model: fitting the world model on autoregressive rollouts, so that it learns from its own compounding errors.

Citation

If you use this code, please cite:

@misc{heyrman2026tgi,
  author        = {Heyrman, Matthias and Hutter, Marco},
  title         = {Terrain-Grounded Imagination: A Recipe for Training Perceptive Legged Locomotion through a World Model},
  year          = {2026},
  eprint        = {2611.41771},
  archivePrefix = {arXiv},
  primaryClass  = {cs.RO},
  url           = {https://arxiv.org/abs/2611.41771}
}

If you use the foothold prediction model or the G1 environments in fpm/, please also cite:

@misc{heyrman2026watch,
  author        = {Heyrman, Matthias and Li, Chenhao and Dadiotis, Ioannis and Hutter, Marco},
  title         = {Watch Your Step: Anticipated Perception for Humanoid Locomotion},
  year          = {2026},
  eprint        = {2610.29612},
  archivePrefix = {arXiv}
}

License

© 2026 ETH Zurich
Created by: Matthias Heyrman and Marco Hutter
Licensed under the MIT License (see LICENSE).

Third-party files keep their original license (see licenses/dependencies):

  • fpm/src/fpm/assets/data/G1/ is the Unitree G1 (29 DoF, rev 1.0) model from unitree_ros, converted to USD, BSD-3-Clause.
  • tgi/src/tgi/assets/g1_kinematics.xml and tgi_g1_3d/src/tgi_g1_3d/assets/g1_kinematics.xml are the Unitree G1 model from mjlab with the meshes removed, Apache-2.0.
  • tgi/src/tgi/assets/unitree_g1/ is the Unitree G1 (29 DoF) MuJoCo model from unitree_mujoco, BSD-3-Clause.
  • tgi_anymal/src/tgi_anymal/assets/anymal_d_kinematics_col.xml is the ANYmal-D model from anymal_d_simple_description with the meshes removed and collision spheres added, BSD-3-Clause.

The ANYmal-D robot model and its ANYdrive actuator network are not part of this repository; Isaac Lab downloads them from its asset server.

Nearby in the ranking

AI Rank for iPhone

Follow AI model rankings

Download on the App Store