Check system type for SET_ATTITUDE_TARGET attitude publising

Check if system type is VTOL and publish attitude to proper uORB topic
This commit is contained in:
Ildar Sadykov 2019-10-09 15:20:19 +03:00 committed by Nuno Marques
parent 8bf60662fa
commit 35b0778499
2 changed files with 23 additions and 1 deletions

View File

@ -85,6 +85,20 @@ MavlinkReceiver::MavlinkReceiver(Mavlink *parent) :
_parameters_manager(parent),
_mavlink_timesync(parent)
{
unsigned int system_type = _mavlink->get_system_type();
if (system_type == MAV_TYPE_VTOL_DUOROTOR ||
system_type == MAV_TYPE_VTOL_QUADROTOR ||
system_type == MAV_TYPE_VTOL_TILTROTOR ||
system_type == MAV_TYPE_VTOL_RESERVED2 ||
system_type == MAV_TYPE_VTOL_RESERVED3 ||
system_type == MAV_TYPE_VTOL_RESERVED4 ||
system_type == MAV_TYPE_VTOL_RESERVED5) {
_is_vtol = true;
} else {
_is_vtol = false;
}
}
void
@ -1411,7 +1425,12 @@ MavlinkReceiver::handle_message_set_attitude_target(mavlink_message_t *msg)
}
}
_att_sp_pub.publish(att_sp);
if (!_is_vtol) {
_att_sp_pub.publish(att_sp);
} else {
_mc_virtual_att_sp_pub.publish(att_sp);
}
}
/* Publish attitude rate setpoint if bodyrate and thrust ignore bits are not set */

View File

@ -229,6 +229,7 @@ private:
uORB::Publication<position_setpoint_triplet_s> _pos_sp_triplet_pub{ORB_ID(position_setpoint_triplet)};
uORB::Publication<vehicle_attitude_s> _attitude_pub{ORB_ID(vehicle_attitude)};
uORB::Publication<vehicle_attitude_setpoint_s> _att_sp_pub{ORB_ID(vehicle_attitude_setpoint)};
uORB::Publication<vehicle_attitude_setpoint_s> _mc_virtual_att_sp_pub{ORB_ID(mc_virtual_attitude_setpoint)};
uORB::Publication<vehicle_global_position_s> _global_pos_pub{ORB_ID(vehicle_global_position)};
uORB::Publication<vehicle_gps_position_s> _gps_pub{ORB_ID(vehicle_gps_position)};
uORB::Publication<vehicle_land_detected_s> _land_detector_pub{ORB_ID(vehicle_land_detected)};
@ -275,6 +276,8 @@ private:
hrt_abstime _last_utm_global_pos_com{0};
bool _is_vtol{false};
DEFINE_PARAMETERS(
(ParamFloat<px4::params::BAT_CRIT_THR>) _param_bat_crit_thr,
(ParamFloat<px4::params::BAT_EMERGEN_THR>) _param_bat_emergen_thr,