FTH 0 · The humanoid's body|INEMA.CLUB-PRO

Lesson 5 · 15 min

Feeling its own body: IMU, encoders, force and touch

A standing humanoid is always falling a little and correcting itself. To do that, it needs to know how it is tilted, where each joint is, and how much weight is on each foot. In this lesson you read the sensors the G1 MJCF declares, add the ones that are missing without editing the file, and check the reading against the robot's weight.

Start the lesson
A humanoid robot foot resting on a metal force plate on the laboratory floor, with thin cables coming out of the plate.

In this lesson you will

  1. 1Proprioception × perception: what each sensor answers
  2. 2Why the accelerometer at rest shows 9.8
  3. 3Add a sensor with MjSpec, without touching the Menagerie file
  4. 4Ankle force × ground force: the difference is the foot

Goal: read the IMU and the force on each foot of the standing G1 and check that the sum of the ground contacts matches the robot's weight.

01What the humanoid feels

The first four answer "how is my body"; the last one, "what is around me". Click each one.

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

Sensors that the MJCF does not declare do not exist in the simulation until you add them.

02Four readings to get right

Click each one.

1. 9.8 at rest

The accelerometer measures the force holding the sensor up, not the motion: at rest on the floor, it reads 9.8 m/s² upward. In free fall, it would read zero.

This is how the IMU knows which way is "down" and, from that, the tilt.

03Read and add sensors

The excerpt shows how the script adds the three sensors; the block runs for 1 s with the G1 at rest.

Excerpt from kit/sensores.py
spec = mujoco.MjSpec.from_file(str(fth.caminho(MODELO)))
spec.add_sensor(name="orientacao_pelve", type=mujoco.mjtSensor.mjSENS_FRAMEQUAT,
                objtype=mujoco.mjtObj.mjOBJ_SITE, objname="imu_in_pelvis")
for lado, sitio in (("esq", "left_foot"), ("dir", "right_foot")):
    spec.add_sensor(name=f"forca_pe_{lado}", type=mujoco.mjtSensor.mjSENS_FORCE,
                    objtype=mujoco.mjtObj.mjOBJ_SITE, objname=sitio)
m = spec.compile()
Terminal · G1 at rest for 1 s
F=${FTH:-$HOME/fth}; cd $F/anatomia && . $F/.venv/bin/activate
python3 kit/sensores.py --segundos 1
Example from the repository
G1 parado 1 s · 7 sensores (4 do arquivo + 3 acrescentados)
  imu-torso-angular-velocity         [0. 0. 0.]
  imu-torso-linear-acceleration      [0.  0.  9.8]
  imu-pelvis-angular-velocity        [0. 0. 0.]
  imu-pelvis-linear-acceleration     [0.  0.  9.8]
IMU (pelve): inclinação lateral 0.0° · frente/trás -0.1°
sensor de força no tornozelo: pé esquerdo 158 N · pé direito 157 N
contatos com o chão:          pé esquerdo 164 N · pé direito 163 N
soma dos contatos / peso do robô (327 N): 1.00

Gyroscopes at zero, accelerometers at 9.8 upward, tilt near zero, and the weight split between the two feet.

04Practice

Read, check, and add a sensor of your own.

E1 · The G1 at rest

3 min

Run the block and check the last three lines.

Done when: python3 kit/sensores.py ends with soma dos contatos / peso do robô (327 N): 1.00.

E2 · Longer at rest

3 min

Run with --segundos 3. If the robot were slipping or sinking, the ratio would change.

Done when: python3 kit/sensores.py --segundos 3 | tail -1 → soma dos contatos / peso do robô (327 N): 1.00.

E3 · A sensor of your own

10 min

Copy kit/sensores.py to kit/meus_sensores.py (in the same folder, because it imports fth.py) and add a framequat on the imu_in_torso site, with the venv active.

Done when: cd ~/fth/anatomia && python3 kit/meus_sensores.py | head -1 → G1 parado 1 s · 8 sensores (4 do arquivo + 4 acrescentados).

05Lesson quiz

The explanation appears after you answer.

Question 1 of 3

The pelvis accelerometer of the resting G1 reads [0, 0, 9.8]. What does that mean?skill

06In three sentences

BodyIMU, encoders, and force tell you how the body is doing; camera and LiDAR tell you what's around it.
APIA missing sensor goes in through MjSpec, without editing Menagerie.
CheckAt rest, the sum of the contacts is the weight: 327 N on the G1.

To go further

Previous lessonNext lesson