Geometry Messages (C++)

Spatial types in horus::msg::. Include via <horus/msg/geometry.hpp>.

Quick Reference

TypeSizeKey FieldsUse Case
Twist56 Blinear[3], angular[3]3D velocity
Pose2D32 Bx, y, theta2D robot pose
Pose3D64 Bposition (Point3), orientation (Quaternion)3D pose
Point324 Bx, y, z3D point
Vector324 Bx, y, z3D vector
Quaternion32 Bx, y, z, w3D rotation
TransformStamped64 Btranslation[3], rotation[4]TF tree data
PoseStamped72 BPose3D + timestamp_nsTimestamped pose
PoseWithCovariance~360 BPose3D + covariance[36]Uncertain pose
TwistWithCovariance~344 BTwist + covariance[36]Uncertain velocity
Accel56 Blinear[3], angular[3]3D acceleration
AccelStamped64 BAccel + timestamp_nsTimestamped 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