VTOL state check for attitude setpoint publish

This commit is contained in:
Ildar Sadykov
2019-10-26 18:29:16 +01:00
committed by Nuno Marques
parent 35b0778499
commit c8edac0a1d
2 changed files with 42 additions and 25 deletions
+37 -25
View File
@@ -99,6 +99,7 @@ MavlinkReceiver::MavlinkReceiver(Mavlink *parent) :
} else {
_is_vtol = false;
}
}
void
@@ -1401,36 +1402,47 @@ MavlinkReceiver::handle_message_set_attitude_target(mavlink_message_t *msg)
}
if (!offboard_control_mode.ignore_thrust) { // dont't overwrite thrust if it's invalid
// Fill correct field by checking frametype
// TODO: add as needed
switch (_mavlink->get_system_type()) {
case MAV_TYPE_GENERIC:
break;
if (!_is_vtol) {
// Fill correct field by checking frametype
// TODO: add as needed
switch (_mavlink->get_system_type()) {
case MAV_TYPE_GENERIC:
break;
case MAV_TYPE_FIXED_WING:
att_sp.thrust_body[0] = set_attitude_target.thrust;
break;
case MAV_TYPE_FIXED_WING:
att_sp.thrust_body[0] = set_attitude_target.thrust;
break;
case MAV_TYPE_QUADROTOR:
case MAV_TYPE_HEXAROTOR:
case MAV_TYPE_OCTOROTOR:
case MAV_TYPE_TRICOPTER:
case MAV_TYPE_HELICOPTER:
att_sp.thrust_body[2] = -set_attitude_target.thrust;
break;
case MAV_TYPE_QUADROTOR:
case MAV_TYPE_HEXAROTOR:
case MAV_TYPE_OCTOROTOR:
case MAV_TYPE_TRICOPTER:
case MAV_TYPE_HELICOPTER:
att_sp.thrust_body[2] = -set_attitude_target.thrust;
break;
case MAV_TYPE_GROUND_ROVER:
att_sp.thrust_body[0] = set_attitude_target.thrust;
break;
case MAV_TYPE_GROUND_ROVER:
att_sp.thrust_body[0] = set_attitude_target.thrust;
break;
}
_att_sp_pub.publish(att_sp);
} else {
if (_vtol_vehicle_status_sub.updated()) {
_vtol_vehicle_status_sub.copy(&_vtol_vehicle_status);
}
if (_vtol_vehicle_status.vtol_in_rw_mode) {
att_sp.thrust_body[2] = -set_attitude_target.thrust;
_mc_virtual_att_sp_pub.publish(att_sp);
} else {
att_sp.thrust_body[0] = set_attitude_target.thrust;
_fw_virtual_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 */