Geometry Messages (C++)
Spatial types in horus::msg::. Include via <horus/msg/geometry.hpp>.
Quick Reference
| Type | Size | Key Fields | Use Case |
|---|---|---|---|
Twist | 56 B | linear[3], angular[3] | 3D velocity |
Pose2D | 32 B | x, y, theta | 2D robot pose |
Pose3D | 64 B | position (Point3), orientation (Quaternion) | 3D pose |
Point3 | 24 B | x, y, z | 3D point |
Vector3 | 24 B | x, y, z | 3D vector |
Quaternion | 32 B | x, y, z, w | 3D rotation |
TransformStamped | 64 B | translation[3], rotation[4] | TF tree data |
PoseStamped | 72 B | Pose3D + timestamp_ns | Timestamped pose |
PoseWithCovariance | ~360 B | Pose3D + covariance[36] | Uncertain pose |
TwistWithCovariance | ~344 B | Twist + covariance[36] | Uncertain velocity |
Accel | 56 B | linear[3], angular[3] | 3D acceleration |
AccelStamped | 64 B | Accel + timestamp_ns | Timestamped accel |
Twist — 3D Velocity
horus::msg::Twist twist{};
twist.linear[0] = 0.5; // vx (m/s) — forward
twist.linear[1] = 0.0; // vy — lateral (holonomic only)
twist.linear[2] = 0.0; // vz — vertical
twist.angular[0] = 0.0; // roll rate (rad/s)
twist.angular[1] = 0.0; // pitch rate
twist.angular[2] = 0.3; // yaw rate
twist.timestamp_ns = 0;
Pose2D — 2D Robot Position
The simplest pose — x, y, heading:
horus::msg::Pose2D pose{};
pose.x = 1.5; // meters
pose.y = 2.0; // meters
pose.theta = 0.785; // radians (45 degrees)
pose.timestamp_ns = 0;
Quaternion — 3D Rotation
Always normalize. w=1, x=y=z=0 is identity (no rotation):
horus::msg::Quaternion q{};
q.x = 0.0; q.y = 0.0; q.z = 0.0; q.w = 1.0; // identity
// 90° rotation around Z axis:
q.x = 0.0; q.y = 0.0; q.z = 0.7071; q.w = 0.7071;
TransformStamped — For TF Tree
Used internally by TransformFrame, but also publishable:
horus::msg::TransformStamped tf{};
tf.translation[0] = 0.2; // x offset (meters)
tf.translation[1] = 0.0;
tf.translation[2] = 0.3; // z offset (height)
tf.rotation[0] = 0.0; // qx
tf.rotation[1] = 0.0; // qy
tf.rotation[2] = 0.0; // qz
tf.rotation[3] = 1.0; // qw (identity)
tf.timestamp_ns = 0;
Odometry Uses Pose2D + Twist
// Odometry combines position and velocity:
auto odom = sub_->recv();
if (odom) {
double x = odom->get()->pose.x;
double y = odom->get()->pose.y;
double heading = odom->get()->pose.theta;
double vx = odom->get()->twist.linear[0];
double wz = odom->get()->twist.angular[2];
}
See Also
- Sensor Messages — Odometry uses Pose2D + Twist
- TransformFrame API — uses TransformStamped internally
- Navigation Messages — NavGoal uses Pose2D