FTH 2 · From simulator to ground|INEMA.CLUB-PRO

Lesson 4 · 16 min

The real actuator: latency, torque limit and actuator network

Between the policy deciding and the motor turning there is a network, the controller loop and the motor PD. In this lesson you measure the "real robot" latency (delay) with a step on the knee, count the falls that 20 and 40 ms cause under a push, and compensate the kp identified in lesson 3.

Start the lesson
A robot rotary actuator on a bench test with an inertia disc and a torque sensor, with a blurred oscilloscope in the background.

In this lesson you will

  1. 1The layers of time: policy at 50 Hz, network, PD at 500 Hz–1 kHz
  2. 2Native latency in MuJoCo 3.5+: the actuator's delay attribute
  3. 3Falls under a push with 0, 20, and 40 ms of latency
  4. 4Compensate the identified kp and watch the "real" robot walk

Goal: measure the actuator latency on the bench, count the falls it causes under a push, and compensate kp in the command.

01The path from command to torque

Click each block.

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

Latency and saturation are invisible in a calm walk and show up under a push.

02Three ways to model the actuator

From the simplest to what you use when the simple one is not enough.

1. Ideal PD

What MuJoCo and Isaac Lab do without you asking: the torque comes out instantly, exactly equal to the PD. It is the "sim" from lesson 1.

03Measure the latency and count the falls

--medir gives a 0.3 rad step at the knee with the robot hanging. --ms runs the walk with 6 pushes (120, 150, and 180 N for 0.2 s, forward and sideways) per latency.

Terminal · measure the latency on the bench
F=${FTH:-$HOME/fth}; cd $F/sim2real && . $F/.venv/bin/activate
python3 kit/atraso.py --medir
Terminal · falls by latency
F=${FTH:-$HOME/fth}; cd $F/sim2real && . $F/.venv/bin/activate
python3 kit/atraso.py --ms 0 20 40
Example from the repository
degrau de 0,3 rad no joelho esquerdo, robô pendurado: tempo até o encoder mexer 0,005 rad
  sim:               8 ms
  real:             30 ms
atraso medido (real − sim): 22 ms

The "real" takes 22 ms longer than the sim to move the knee: the 20 ms of hidden latency plus a bit from the softer kp, which also slows the response.

04Compensate kp in the command

Lesson 3 identified kp ≈ 0.57 of the commanded value. Sending 1/0.57 ≈ 1.75 times the kp, the "real" motor delivers close to what the policy expects.

Terminal · compensated kp
F=${FTH:-$HOME/fth}; cd $F/sim2real && . $F/.venv/bin/activate
python3 kit/dois_mundos.py --kp-comando 1.75; echo "saída: $?"
Example from the repository
política: unitree_rl_lab G1 29 GDL velocity v0 (ONNX, 480 entradas) · comando 0.50 m/s · 10 s
sim                          queda: não · andou 5.1 m em 10 s (vel. 0.51 m/s; pedida 0.50)
real simulado                queda: não · andou 4.5 m em 10 s (vel. 0.45 m/s; pedida 0.50)
saída: 0

The "simulated real" now walks 4.5 m and doesn't fall (exit 0). The sim, with the stiffer kp, keeps walking. The latency, the mass, and the friction are still there: the policy handles it, because the biggest difference was corrected.

05Practice

Actuator timing and torque.

E1 · Measured latency

3 min

Apply the step to the knee in both worlds.

Done when: python3 kit/atraso.py --medir → atraso medido (real − sim): 22 ms.

E2 · Falls from latency

5 min

Run the walk with pushes at 0, 20, and 40 ms.

Done when: python3 kit/atraso.py --ms 0 20 40 → 0 ms 2/6, 20 ms 3/6, 40 ms 6/6.

E3 · Compensate and walk

5 min

Use the kp you identified in lesson 3 (1 divided by it) and run both worlds again.

Done when: python3 kit/dois_mundos.py --kp-comando 1.75; echo "saída: $?" → real simulado … queda: não and saída: 0.

06Lesson quiz

The explanation appears after your answer.

Question 1 of 3

With no push, the policy walks with the "real" robot's 20 ms of latency (lesson 1). With a push, 40 ms knocks it down in 6 of 6. What does this teach?skill

07In three sentences

MeasurementA step on the knee with the robot hanging measures the latency: 22 ms.
EffectUnder a push, falls rise from 2/6 (0 ms) to 6/6 (40 ms).
FixSending kp divided by the identified value makes the "simulated real" walk without falling.

Going further

Previous lessonNext lesson