read() updated every physics frame.
Signature
Usage
Return Value
| Field | Type | Description |
|---|---|---|
read() | () => Float64Array | Current sensor reading from data.sensordata |
dim | number | Number of values (e.g., 3 for a force sensor, 1 for a scalar) |
name | Sensors | Sensor name |
Sensor Types
Common MuJoCo sensor types and their dimensions:| Sensor Type | dim | Description |
|---|---|---|
touch | 1 | Contact normal force |
accelerometer | 3 | Linear acceleration |
gyro | 3 | Angular velocity |
force | 3 | Constraint force |
torque | 3 | Constraint torque |
jointpos | 1 | Joint position |
jointvel | 1 | Joint velocity |
framepos | 3 | Frame position |
framequat | 4 | Frame orientation |
Notes
- The
read()array is updated every frame viauseAfterPhysicsStep - If the sensor doesn’t exist,
read()returns an emptyFloat64Array - For enumerating all sensors, use
api.getSensors() - The
nameparameter acceptsstringby default, or a union type if you’ve declared aRegisteraugmentation