velocity_sensor
A directional velocity sensor. Reports the host contraption's linear velocity component along the body-frame axis the block is mounted on.
Axis convention. Each sensor is mounted along one body-frame axis (set at place-time, not affected by sub-level rotation). At sub-level identity orientation, body axes equal world axes (body +X = east, +Y = up, +Z = south). Internally the sensor projects the contraption's global velocity onto its mounted axis direction (transformed into world frame), so three orthogonally-mounted sensors give the contraption's velocity in its own body frame.
| getVelocity() | Get the velocity component along the sensor's mounted axis. |
|---|---|
| getAxis() | Get the body-frame axis the sensor measures along. |
- getVelocity()Source
Get the velocity component along the sensor's mounted axis. Sign: positive when the contraption is moving along the axis-positive direction (e.g. east for an X-mounted sensor on an unrotated contraption). Has a deadband: returns 0 if the projected component's magnitude is below 0.05 m/s. When the host is not on a sub-level (sitting on stationary ground), returns 0.
Returns
numberThe signed velocity in m/s.
- getAxis()Source
Get the body-frame axis the sensor measures along. Lets a Lua script distinguish three orthogonally-mounted sensors to reconstruct the contraption's body-frame velocity vector
(vx, vy, vz). The axis label is fixed at place-time; the direction it represents in world frame rotates with the contraption.Returns
stringThe axis as "x", "y", or "z".