novaphy.sensors.SensorIMU¶
Inertial measurement unit attached to one or more model Site instances. Reports linear acceleration (accelerometer) and angular velocity (gyroscope) in the sensor-local frame.
The accelerometer reports specific force (proper acceleration), so at rest
on a surface it reads +g upward. A free-fall reading converges to zero when
body acceleration is available directly or after the finite-difference path
has a previous-velocity sample.
Methods¶
| Method | Description |
|---|---|
update(state, dt, gravity=None) |
Compute IMU readings from the current state. |
Attributes¶
| Attribute | Description |
|---|---|
accelerometer |
(N, 3) numpy array of accelerometer readings. |
gyroscope |
(N, 3) numpy array of gyroscope readings. |
num_sensors |
Number of attached sensors. |
Current boundaries¶
- With
gravity=None, the implementation usesmodel.gravity_for_world(0)for every attached site; it does not select gravity from each site's world. - If the state has no
body_qdd, the firstupdate()has no previous velocity sample and assumes zero world acceleration. Under gravity, that first reading is therefore the sensor-frame value of-g, including in free fall. Subsequent calls estimate acceleration by finite differences.
Example¶
from novaphy import sensors
imu = sensors.SensorIMU(model, sites="imu_*")
imu.update(state, dt=1.0 / 120.0)
print(imu.accelerometer)