E1 · The G1 at rest
3 minRun 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.
Lesson 5 · 15 min
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
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.
The first four answer "how is my body"; the last one, "what is around me". Click each one.
Sensors that the MJCF does not declare do not exist in the simulation until you add them.
Click each one.
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.
sensores.py opens the file with mujoco.MjSpec.from_file, adds an orientation sensor (framequat) on the pelvis IMU and a force sensor on each foot, and compiles.
The Menagerie file stays untouched: you change the robot in your own script, versioned together with your code.
The force sensor at the foot site measures what passes from the foot to the leg; the contact measures what the floor pushes back. The difference, about 6 N, is the weight of the foot itself (0.61 kg in the model).
On a real robot, the load cell sits at the ankle for the same reason.
At rest, the sum of the contact forces must equal the weight: 33.3 kg × 9.81 = 327 N. The 1.00 ratio shows the robot is supported only by its feet and with no push.
If it comes out below 1, something is holding the robot up (another part touching the floor, an external force).
soma dos contatos / peso do robô (327 N): 1.00
The excerpt shows how the script adds the three sensors; the block runs for 1 s with the G1 at rest.
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()F=${FTH:-$HOME/fth}; cd $F/anatomia && . $F/.venv/bin/activate
python3 kit/sensores.py --segundos 1G1 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.
Reading [0. 0. 9.8] and concluding that the robot is moving up is the classic mistake. The accelerometer measures specific force: at rest, it shows the floor's reaction against gravity. To see real motion, compare with the gyroscope and with the pelvis height.
Read, check, and add a sensor of your own.
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.
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.
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).
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
Question 2 of 3
The foot force sensor read 158 N and the ground contact read 164 N. Why the difference?
Question 3 of 3
Why add sensors through MjSpec instead of editing Menagerie's g1.xml?
Pick an option. The explanation shows up after you answer.