diff --git a/src/modules/uuv_att_control/uuv_att_control.cpp b/src/modules/uuv_att_control/uuv_att_control.cpp index 719f4c59d6..7a8babda07 100644 --- a/src/modules/uuv_att_control/uuv_att_control.cpp +++ b/src/modules/uuv_att_control/uuv_att_control.cpp @@ -294,12 +294,38 @@ void UUVAttitudeControl::Run() _vcontrol_mode.flag_control_attitude_enabled) { /* publish the actuator controls */ _actuator_controls_pub.publish(_actuators); - + publishTorqueSetpoint(0); + publishThrustSetpoint(0); } perf_end(_loop_perf); } +void UUVAttitudeControl::publishTorqueSetpoint(const hrt_abstime ×tamp_sample) +{ + vehicle_torque_setpoint_s v_torque_sp = {}; + v_torque_sp.timestamp = hrt_absolute_time(); + v_torque_sp.timestamp_sample = timestamp_sample; + v_torque_sp.xyz[0] = _actuators.control[actuator_controls_s::INDEX_ROLL]; + v_torque_sp.xyz[1] = _actuators.control[actuator_controls_s::INDEX_PITCH]; + v_torque_sp.xyz[2] = _actuators.control[actuator_controls_s::INDEX_YAW]; + + _vehicle_torque_setpoint_pub.publish(v_torque_sp); +} + +void UUVAttitudeControl::publishThrustSetpoint(const hrt_abstime ×tamp_sample) +{ + vehicle_thrust_setpoint_s v_thrust_sp = {}; + v_thrust_sp.timestamp = hrt_absolute_time(); + v_thrust_sp.timestamp_sample = timestamp_sample; + v_thrust_sp.xyz[0] = _actuators.control[actuator_controls_s::INDEX_THROTTLE]; + v_thrust_sp.xyz[1] = 0.0f; + v_thrust_sp.xyz[2] = 0.0f; + + _vehicle_thrust_setpoint_pub.publish(v_thrust_sp); +} + + int UUVAttitudeControl::task_spawn(int argc, char *argv[]) { UUVAttitudeControl *instance = new UUVAttitudeControl(); diff --git a/src/modules/uuv_att_control/uuv_att_control.hpp b/src/modules/uuv_att_control/uuv_att_control.hpp index 095bc80502..f41fdaa103 100644 --- a/src/modules/uuv_att_control/uuv_att_control.hpp +++ b/src/modules/uuv_att_control/uuv_att_control.hpp @@ -69,6 +69,8 @@ #include #include #include +#include +#include #include using matrix::Eulerf; @@ -98,7 +100,12 @@ public: bool init(); private: + void publishTorqueSetpoint(const hrt_abstime ×tamp_sample); + void publishThrustSetpoint(const hrt_abstime ×tamp_sample); + uORB::Publication _actuator_controls_pub{ORB_ID(actuator_controls_0)}; + uORB::Publication _vehicle_thrust_setpoint_pub{ORB_ID(vehicle_thrust_setpoint)}; + uORB::Publication _vehicle_torque_setpoint_pub{ORB_ID(vehicle_torque_setpoint)}; uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};