mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-05 23:43:58 -04:00
Plane: support DO_VTOL_TRANSITION as a mission item
This commit is contained in:
parent
3a5e4c80ca
commit
76400a9959
@ -1626,7 +1626,11 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg)
|
||||
break;
|
||||
|
||||
case MAV_CMD_DO_VTOL_TRANSITION:
|
||||
result = plane.quadplane.handle_do_vtol_transition(packet);
|
||||
if (!plane.quadplane.handle_do_vtol_transition((enum MAV_VTOL_STATE)packet.param1)) {
|
||||
result = MAV_RESULT_FAILED;
|
||||
} else {
|
||||
result = MAV_RESULT_ACCEPTED;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -218,6 +218,10 @@ bool Plane::start_command(const AP_Mission::Mission_Command& cmd)
|
||||
cmd.content.mount_control.yaw);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MAV_CMD_DO_VTOL_TRANSITION:
|
||||
plane.quadplane.handle_do_vtol_transition((enum MAV_VTOL_STATE)cmd.content.do_vtol_transition.target_state);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -948,33 +948,38 @@ bool QuadPlane::init_mode(void)
|
||||
/*
|
||||
handle a MAVLink DO_VTOL_TRANSITION
|
||||
*/
|
||||
bool QuadPlane::handle_do_vtol_transition(const mavlink_command_long_t &packet)
|
||||
bool QuadPlane::handle_do_vtol_transition(enum MAV_VTOL_STATE state)
|
||||
{
|
||||
if (!available()) {
|
||||
plane.gcs_send_text_fmt(MAV_SEVERITY_NOTICE, "VTOL not available");
|
||||
return MAV_RESULT_FAILED;
|
||||
return false;
|
||||
}
|
||||
if (plane.control_mode != AUTO) {
|
||||
plane.gcs_send_text_fmt(MAV_SEVERITY_NOTICE, "VTOL transition only in AUTO");
|
||||
return MAV_RESULT_FAILED;
|
||||
return false;
|
||||
}
|
||||
switch ((uint8_t)packet.param1) {
|
||||
switch (state) {
|
||||
case MAV_VTOL_STATE_MC:
|
||||
if (!plane.auto_state.vtol_mode) {
|
||||
plane.gcs_send_text_fmt(MAV_SEVERITY_NOTICE, "Entered VTOL mode");
|
||||
}
|
||||
plane.auto_state.vtol_mode = true;
|
||||
return MAV_RESULT_ACCEPTED;
|
||||
return true;
|
||||
|
||||
case MAV_VTOL_STATE_FW:
|
||||
if (plane.auto_state.vtol_mode) {
|
||||
plane.gcs_send_text_fmt(MAV_SEVERITY_NOTICE, "Exited VTOL mode");
|
||||
}
|
||||
plane.auto_state.vtol_mode = false;
|
||||
return MAV_RESULT_ACCEPTED;
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
plane.gcs_send_text_fmt(MAV_SEVERITY_NOTICE, "Invalid VTOL mode");
|
||||
return MAV_RESULT_FAILED;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
return available() && assisted_flight;
|
||||
}
|
||||
|
||||
bool handle_do_vtol_transition(const mavlink_command_long_t &packet);
|
||||
bool handle_do_vtol_transition(enum MAV_VTOL_STATE state);
|
||||
|
||||
bool do_vtol_takeoff(const AP_Mission::Mission_Command& cmd);
|
||||
bool do_vtol_land(const AP_Mission::Mission_Command& cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user