diff --git a/src/modules/uuv_att_control/uuv_att_control.cpp b/src/modules/uuv_att_control/uuv_att_control.cpp index 6f85d0e83e..bf3e12a5fd 100644 --- a/src/modules/uuv_att_control/uuv_att_control.cpp +++ b/src/modules/uuv_att_control/uuv_att_control.cpp @@ -112,6 +112,11 @@ void UUVAttitudeControl::vehicle_attitude_setpoint_poll() } } +void UUVAttitudeControl::vehicle_rates_setpoint_poll() +{ + _vehicle_rates_setpoint_sub.update(&_vehicle_rates_sp); +} + void UUVAttitudeControl::constrain_actuator_commands(float roll_u, float pitch_u, float yaw_u, float thrust_u) { @@ -186,6 +191,10 @@ void UUVAttitudeControl::control_attitude_geo(const vehicle_attitude_s &att, con float pitch_body = _vehicle_attitude_sp.pitch_body; float yaw_body = _vehicle_attitude_sp.yaw_body; + float roll_rate_desired = _vehicle_rates_sp.roll; + float pitch_rate_desired = _vehicle_rates_sp.pitch; + float yaw_rate_desired = _vehicle_rates_sp.yaw; + /* get attitude setpoint rotational matrix */ Dcmf _rot_des = Eulerf(roll_body, pitch_body, yaw_body); @@ -205,9 +214,9 @@ void UUVAttitudeControl::control_attitude_geo(const vehicle_attitude_s &att, con e_R_vec(1) = e_R(0, 2); /**< Pitch */ e_R_vec(2) = e_R(1, 0); /**< Yaw */ - omega(0) = _angular_velocity.xyz[0] - 0.0f; - omega(1) = _angular_velocity.xyz[1] - 0.0f; - omega(2) = _angular_velocity.xyz[2] - 0.0f; + omega(0) = _angular_velocity.xyz[0] - roll_rate_desired; + omega(1) = _angular_velocity.xyz[1] - pitch_rate_desired; + omega(2) = _angular_velocity.xyz[2] - yaw_rate_desired; /**< P-Control */ torques(0) = - e_R_vec(0) * _param_roll_p.get(); /**< Roll */ @@ -306,6 +315,7 @@ void UUVAttitudeControl::run() orb_copy(ORB_ID(vehicle_local_position), _local_pos_sub, &_local_pos); vehicle_attitude_setpoint_poll(); + vehicle_rates_setpoint_poll(); vehicle_control_mode_poll(); manual_control_setpoint_poll(); @@ -364,6 +374,8 @@ void UUVAttitudeControl::run() } orb_unsubscribe(_vcontrol_mode_sub); + orb_unsubscribe(_vehicle_attitude_sp_sub); + orb_unsubscribe(_angular_velocity_sub); orb_unsubscribe(_manual_control_setpoint_sub); orb_unsubscribe(_vehicle_attitude_sub); orb_unsubscribe(_local_pos_sub); diff --git a/src/modules/uuv_att_control/uuv_att_control.hpp b/src/modules/uuv_att_control/uuv_att_control.hpp index 05c7c1f9b6..b719389d75 100644 --- a/src/modules/uuv_att_control/uuv_att_control.hpp +++ b/src/modules/uuv_att_control/uuv_att_control.hpp @@ -122,6 +122,7 @@ private: uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)}; int _vehicle_attitude_sp_sub{-1}; /**< vehicle attitude setpoint */ + uORB::Subscription _vehicle_rates_setpoint_sub{ORB_ID(vehicle_rates_setpoint)}; /**< vehicle bodyrates setpoint subscriber */ int _battery_status_sub{-1}; /**< battery status subscription */ int _vehicle_attitude_sub{-1}; /**< control state subscription */ int _angular_velocity_sub{-1}; /**< vehicle angular velocity subscription */ @@ -135,20 +136,18 @@ private: vehicle_attitude_s _vehicle_attitude {}; /**< control state */ vehicle_angular_velocity_s _angular_velocity{}; /**< angular velocity */ vehicle_attitude_setpoint_s _vehicle_attitude_sp {};/**< vehicle attitude setpoint */ + vehicle_rates_setpoint_s _vehicle_rates_sp {}; /**< vehicle bodyrates setpoint */ vehicle_control_mode_s _vcontrol_mode {}; /**< vehicle control mode */ sensor_combined_s _sensor_combined{}; vehicle_local_position_s _local_pos{}; /**< vehicle local position */ - SubscriptionData _vehicle_acceleration_sub{ORB_ID(vehicle_acceleration)}; hrt_abstime _control_position_last_called{0}; /**