FTH 1 · Teaching it to walk|INEMA.CLUB-PRO

Lesson 1 · 16 min

Why locomotion became RL

The Unitree G1 in this course walks because a neural network sends 29 joint targets every 20 ms. In this lesson you set up the bench, run the ready-made Unitree G1 gait policy in MuJoCo, watch the same robot fall without it, and see why classical control gave way to RL in massive simulation.

Start the lesson
Charcoal-gray industrial humanoid robot with a black visor, taking a long step down a dark laboratory corridor.

In this lesson you will

  1. 1Classical control (model + optimization) × policy learned in simulation
  2. 2The G1's open gait policy (unitree_rl_lab) walking in MuJoCo
  3. 3With policy: 6.6 m in 10 s. Without policy: fall in 1.4 s
  4. 4The ~/fth workbench with pinned versions

Goal: run the ready-made G1 gait policy in MuJoCo, measure what it does, and compare it with the robot without a policy.

01Two ways to make a humanoid walk

Click each block. The first three are the classical path; the last three are what the course practices.

Click each block in the diagram to see what it does.

MPC lives on as a concept and wherever a guarantee is required. The practice in this course is the right-hand column: simulation, policy and PD.

02What runs in this lesson

Click each stage.

1. The robot

The 29-degree-of-freedom Unitree G1 from MuJoCo Menagerie, pinned to commit 62ab00f (the same one as course 0). Position actuator with the policy's kp and kd.

03Set up the ~/fth bench

If you did course 0, the venv and Menagerie are already there: the block only adds what's missing (onnxruntime, CPU torch, the policy). Pinned versions, tested on Oct 19, 2026.

Terminal · set up ~/fth
F=${FTH:-$HOME/fth}; mkdir -p $F && cd $F
[ -d .venv ] || python3.12 -m venv .venv
. .venv/bin/activate && pip install -q mujoco==3.16.0 numpy pyyaml onnxruntime==1.31.0
pip install -q torch==2.14.1 --index-url https://download.pytorch.org/whl/cpu
[ -d locomocao ] || git clone -q --depth 1 https://github.com/inematds/formacao-fth-locomocao-v72 locomocao
[ -d mujoco_menagerie ] || git clone -q --filter=blob:none --sparse https://github.com/google-deepmind/mujoco_menagerie
(cd mujoco_menagerie && git sparse-checkout add unitree_g1 && git checkout -q 62ab00f)
[ -d unitree_rl_lab ] || git clone -q --filter=blob:none --sparse https://github.com/unitreerobotics/unitree_rl_lab
cd unitree_rl_lab && git sparse-checkout set deploy/robots/g1_29dof/config/policy/velocity
git checkout -q 4960b84 && git log -1 --format='unitree_rl_lab %h (%ad)' --date=short
python3 -c "import mujoco, onnxruntime, torch; print('mujoco', mujoco.__version__, '· onnxruntime', onnxruntime.__version__, '· torch', torch.__version__)"
Example from the repository
unitree_rl_lab 4960b84 (2025-11-19)
mujoco 3.16.0 · onnxruntime 1.31.0 · torch 2.14.1+cpu

Two lines and no errors. Pin the commits: a policy.onnx from another commit may have a different input order. torch comes from PyTorch's CPU wheels page (the course doesn't need a GPU).

04The G1 walking, and the G1 without a policy

10 s asking for 0.7 m/s forward. It exits with 0 if it didn't fall, 1 if it fell.

Terminal · walk with the policy
F=${FTH:-$HOME/fth}; cd $F/locomocao && . $F/.venv/bin/activate
python3 kit/andar_demo.py --vx 0.7 --s 10; echo "saída: $?"
Terminal · PD only, no policy
F=${FTH:-$HOME/fth}; cd $F/locomocao && . $F/.venv/bin/activate
python3 kit/andar_demo.py --vx 0.7 --s 10 --sem-politica
Terminal · ask for 1.0 m/s
F=${FTH:-$HOME/fth}; cd $F/locomocao && . $F/.venv/bin/activate
python3 kit/andar_demo.py --vx 1.0 --s 10 | tail -3
Example from the repository
política: unitree_rl_lab velocity v0 (ONNX) · 480 → 29 · 50 Hz
comando: vx = 0.7 m/s por 10 s · simulação a 500 Hz, política a 50 Hz
andou: 6.6 m para a frente · desvio lateral: 0.5 m · velocidade média: 0.66 m/s
altura final da pelve: 0.77 m
caiu: não
saída: 0

6.6 m in 10 s (0.66 m/s for the 0.70 requested) and the pelvis ends at 0.77 m. The 0.5 m lateral drift is normal: nothing corrects the heading, only the speed.

05Practice

See the policy work before you open up the parts.

E1 · Bench ready

10 min

Run the setup block. If course 0 already set up ~/fth, it only adds what's missing.

Done when: the block ends with unitree_rl_lab 4960b84 (2025-11-19) and mujoco 3.16.0 · onnxruntime 1.31.0 · torch 2.14.1+cpu.

E2 · The G1 walks

3 min

Run the policy at 0.7 m/s for 10 s and note how many meters the pelvis walked.

Done when: python3 kit/andar_demo.py --vx 0.7 --s 10; echo "saída: $?" → caiu: não and saída: 0.

E3 · The contrast

5 min

Run with --sem-politica and write, in one sentence, what keeps the robot upright when it walks.

Done when: the output shows caiu: sim, em t = 1.4 s; your sentence says it's the policy's closed loop (PD alone doesn't correct balance).

06Lesson quiz

The explanation appears after your answer.

Question 1 of 3

What does the G1's gait policy deliver every 20 ms?skill

07In three sentences

ChangeHumanoid gait went from model + optimization to a policy trained in massive simulation.
LayersThe policy sends 29 targets at 50 Hz; each joint's PD produces the torque.
MeasureWith a policy, 6.6 m in 10 s; without it, a fall at 1.4 s.

Going further

Next lesson