Twist
Represents 3D linear velocity and 3D angular velocity. Used for full 6-DOF velocity representation in odometry, navigation, and force/torque control. For 2D mobile robots, prefer the simpler CmdVel.
When to Use
Use Twist when you need full 3D velocity: drones, underwater vehicles, manipulator end-effectors, or any system that moves in all six degrees of freedom. Also used as a component of Odometry and TwistWithCovariance.
ROS2 Equivalent
geometry_msgs/Twist — identical field layout (linear [x, y, z] + angular [x, y, z]).
Rust Example
use horus::prelude::*;
// Drone velocity: 1 m/s forward, 0.5 m/s up, yawing at 0.1 rad/s
let twist = Twist {
linear: [1.0, 0.0, 0.5], // [x, y, z] m/s
angular: [0.0, 0.0, 0.1], // [roll, pitch, yaw] rad/s
timestamp_ns: 0,
};
let topic: Topic<Twist> = Topic::new("velocity")?;
topic.send(twist);
Python Example
import horus
twist = horus.Twist(
linear=[1.0, 0.0, 0.5],
angular=[0.0, 0.0, 0.1],
)
Fields
| Field | Type | Unit | Description |
|---|---|---|---|
linear | [f64; 3] | m/s | Linear velocity [x, y, z] |
angular | [f64; 3] | rad/s | Angular velocity [roll, pitch, yaw] |
timestamp_ns | u64 | ns | Timestamp |
TwistWithCovariance
For uncertainty-aware systems (EKF, navigation stacks), use the covariance variant:
let twist_cov = TwistWithCovariance {
twist: Twist { linear: [1.0, 0.0, 0.0], angular: [0.0, 0.0, 0.1], timestamp_ns: 0 },
covariance: [0.0; 36], // 6x6 row-major: [vx, vy, vz, wx, wy, wz]
};
| Field | Type | Description |
|---|---|---|
twist | Twist | The velocity |
covariance | [f64; 36] | 6x6 covariance matrix (row-major) |
CmdVel vs Twist
| Feature | CmdVel | Twist |
|---|---|---|
| Dimensions | 2D (linear + angular) | 3D (6-DOF) |
| Field types | f32 | f64 |
| Zero-copy | Yes (#[repr(C)], 12 bytes) | Yes (#[repr(C)], 56 bytes) |
| Use case | Mobile robots | Drones, 3D systems |