Force & Tactile Messages (C++)

Force/torque sensing and haptic types in horus::msg::. Include via <horus/msg/force.hpp>.

Quick Reference

TypeKey FieldsUse Case
WrenchStampedforce[3], torque[3]Force/torque sensor
ForceCommandtarget_force[3], target_torque[3], stiffness, dampingForce control
ContactInfoposition[3], normal[3], force_magnitude, in_contactContact detection
HapticFeedbackforce[3], vibration_amplitude/freq, enabledHaptic devices
ImpedanceParametersstiffness[6], damping[6], mass[6]Impedance control

WrenchStamped — Force/Torque Sensor

horus::msg::WrenchStamped wrench{};
wrench.force[0] = 0.0;    // Fx (N)
wrench.force[1] = 0.0;    // Fy (N)
wrench.force[2] = -9.81;  // Fz (N) — gravity
wrench.torque[0] = 0.0;   // Tx (Nm)
wrench.torque[1] = 0.1;   // Ty (Nm)
wrench.torque[2] = 0.0;   // Tz (Nm)
wrench.timestamp_ns = 0;

ForceCommand — Impedance/Force Control

horus::msg::ForceCommand cmd{};
cmd.target_force[2] = -5.0;   // push down 5N
cmd.stiffness = 500.0f;        // N/m
cmd.damping = 10.0f;           // Ns/m
cmd.max_force = 20.0f;         // safety limit

ContactInfo — Collision Detection

// In a contact detection node:
auto contact = contact_sub_->recv();
if (contact && contact->get()->in_contact) {
    double fx = contact->get()->force_magnitude;
    horus::log::warn("contact", "Contact detected, force=" + std::to_string(fx) + "N");
}

See Also