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

Lesson 8 · 16 min

Terrain curriculum and your training plan

Nobody trains stair walking on day one: the terrain and the requested speed grow as the policy succeeds. In this lesson you measure how far up the ladder the ready-made policy goes, read how mjlab and unitree_rl_lab level up, and write your own training plan in a file that a script checks.

Start the lesson
Test track in a dark lab with a wooden ramp, low steps and pebbles, and a humanoid robot climbing the first step attached to a safety rail.

In this lesson you will

  1. 1Steps of 2 and 3 cm pass; from 4 cm up, it falls
  2. 2Curriculum: it moves up if it walked more than 80% of the request, down if it walked less than 50%
  3. 3Command curriculum: the speed range opens 0.1 m/s at a time
  4. 4The plano-treino.md with robot, command, reward, curriculum and evaluation

Goal: measure the ready-made policy's maximum step, read the curriculum rules, and write a training plan with 5 fields that conferir_plano.py approves.

01A terrain curriculum

Click each level. Each robot moves up or down a level on its own, based on how far it walked.

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

Rules read from the code: mjlab mdp/curriculums.py (commit 8bb2bc9) and unitree_rl_lab velocity_env_cfg.py (commit 4960b84).

02How far up the steps the ready-made policy goes

terreno.py uses MjSpec to build a platform of height h 1.5 m from the robot and tells it to walk for 8 s at 0.5 m/s. Passed = it did not fall and the pelvis ended up on top (x > 2.5 m).

Terminal · five steps
F=${FTH:-$HOME/fth}; cd $F/locomocao && . $F/.venv/bin/activate
python3 kit/terreno.py --degraus 0.02 0.03 0.04 0.06 0.10; echo "saída: $?"
Example from the repository
política: unitree_rl_lab velocity v0 (ONNX) · comando vx = 0.5 m/s · 8 s · degrau a 1.5 m
degrau    2 cm: passou (pelve em x = 3.4 m)
degrau    3 cm: passou (pelve em x = 4.1 m)
degrau    4 cm: caiu (pelve em x = 2.0 m)
degrau    6 cm: caiu (pelve em x = 2.0 m)
degrau   10 cm: caiu (pelve em x = 2.2 m)
degraus vencidos: 2/5
saída: 0

2 and 3 cm pass; from 4 cm up, the robot falls at x ≈ 2 m, before getting onto the platform. The steps that fail are the next levels of a curriculum: that is what you retrain for.

03How the repositories move up a level

Two curricula run together in real training. Click each one.

1. Terrain

In mjlab, at the end of each episode, a robot that walked more than 80% of the requested distance moves up one terrain level; one that walked less than 50% moves down. Each robot has its own level: in the same training run, some are on flat ground and others on pebbles.

04Your training plan

Copy the template to ~/fth/treino, replace each [bracket] with your value, and check it. The kit example shows a plan that passes.

File · kit/plano-treino-modelo.md
# Plano de treino de locomoção

Robô: [qual humanoide e qual arquivo, ex.: Unitree G1 29 GDL, unitree_g1/scene.xml do Menagerie 62ab00f]
Comando: [faixa de velocidade, ex.: vx de -0.5 a 1.0 m/s, vy de -0.3 a 0.3 m/s, giro de -0.2 a 0.2 rad/s]
Recompensa: [termos e pesos, ex.: track_linear_velocity 2.0, upright 1.0, action_rate_l2 -0.1]
Currículo: [níveis em ordem, separados por →, ex.: plano → degrau de 5 cm → rampa → pedriscos]
Avaliação: [critério de aprovação com número, ex.: 18/20 episódios de pé com empurrão de 1.0 m/s]
Terminal · copy and check
F=${FTH:-$HOME/fth}; cd $F/locomocao && . $F/.venv/bin/activate
[ -f $F/treino/plano-treino.md ] || cp kit/plano-treino-modelo.md $F/treino/plano-treino.md
python3 kit/conferir_plano.py $F/treino/plano-treino.md; echo "saída: $?"
Terminal · the kit example
F=${FTH:-$HOME/fth}; cd $F/locomocao && . $F/.venv/bin/activate
python3 kit/conferir_plano.py kit/exemplos/plano-treino.md; echo "saída: $?"
Example from the repository
FALTA Robô: não preenchido
FALTA Comando: não preenchido
FALTA Recompensa: não preenchido
FALTA Currículo: não preenchido
FALTA Avaliação: não preenchido
campos ok: 0/5
incompleto
saída: 1

With the template still full of [brackets], all five fields are missing and the script exits with 1. Rules: command with a number and m/s, reward with 2 or more kit terms, curriculum with 3 or more levels separated by →, evaluation with a numeric criterion (X/N or %).

05What you built in this course

Four deliverables. Click each one to see the "done when".

Lessons 1–2Policy

and PD

3 exercises

caiu: não; de pé com PD.

See the lesson
Lessons 3–4Environment

and reward

3 exercises

96 → 29; parado 42,32.

See the lesson
Lessons 5–6Training

and curves

3 exercises

modelo_20.pt; 1 alerta lido.

See the lesson
Lessons 7–8Test

and plan

3 exercises

20/20; plan ok.

See the lesson
At the end of the coursePolicy run, reward measured, training read, test and plan written.
8 lessons
Tap an exercise to see what to do and the "done when".
  1. 1/5

    Policy

    The ready-made policy walking in MuJoCo and the joint PD measured, with the policy's gains understood.

  2. 2/5

    Environment

    The four pieces of the environment and the reward measured term by term, with the weight that turns the game around.

  3. 3/5

    Training

    A PPO training run on CPU with a checkpoint and the curves read, with the reward hacking recognized.

  4. 4/5

    Test

    The policy evaluated with a push and a step, and your training plan checked.

  5. 5/5

    The whole course

    Four deliverables in sequence. Course 2 takes this course's policy from the simulator to the floor.

Order matters: the lesson 8 plan uses the reward from lesson 4 and the test from lesson 7.

06Generate your study plan with dates

Pick a start date and how much time you have per week. The plan lists the practices for each lesson.

07Practice

Measure the limit and plan the next training run.

E1 · The maximum step

5 min

Run the five steps and note the highest one the policy clears.

Done when: python3 kit/terreno.py --degraus 0.02 0.03 0.04 0.06 0.10; echo "saída: $?" → degraus vencidos: 2/5 and saída: 0.

E2 · The failed plan

2 min

Copy the template and check it before filling it in, so you see the script fail it.

Done when: the output shows campos ok: 0/5, incompleto and saída: 1.

E3 · Your plan

20 min

Fill in ~/fth/treino/plano-treino.md with your choices: a curriculum that starts on flat ground and goes through the steps that failed in E1, and an evaluation with a number.

Done when: python3 kit/conferir_plano.py $F/treino/plano-treino.md; echo "saída: $?" → campos ok: 5/5, ok and saída: 0.

08Lesson quiz

The explanation appears after your answer.

Question 1 of 3

In mjlab's terrain curriculum, when does a robot move up a level?skill

09In three sentences

LimitThe finished policy clears 2 cm and 3 cm steps and falls from 4 cm on.
CurriculumTerrain moves up at 80 % of the distance and down below 50 %; the command opens 0.1 m/s at a time.
FlatRobot, command, reward, curriculum, and evaluation written and checked before training.

Going further