mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-02 10:23:25 +08:00
Plane: fail DO_REPOSITION if GUIDED cannot be entered
When DO_REPOSITION asked for a change into GUIDED and the mode change was refused (for example GUIDED being blocked by FLTMODE_GCSBLOCK) the result of set_mode() was ignored. The requested location was still loaded with set_guided_WP() and the command was ACCEPTED, so a vehicle in AUTO stayed in AUTO but flew towards the reposition target. Return MAV_RESULT_FAILED instead, leaving the current mode's navigation alone.
This commit is contained in:
committed by
Peter Barker
parent
f47861a374
commit
0d3e2aaa8e
@@ -587,7 +587,11 @@ MAV_RESULT GCS_MAVLINK_Plane::handle_command_int_do_reposition(const mavlink_com
|
||||
// location is valid load and set
|
||||
if (((int32_t)packet.param2 & MAV_DO_REPOSITION_FLAGS_CHANGE_MODE) ||
|
||||
(plane.control_mode == &plane.mode_guided)) {
|
||||
plane.set_mode(plane.mode_guided, ModeReason::GCS_COMMAND);
|
||||
if (!plane.set_mode(plane.mode_guided, ModeReason::GCS_COMMAND)) {
|
||||
// e.g. GUIDED blocked by FLTMODE_GCSBLOCK; don't touch the
|
||||
// current mode's navigation target
|
||||
return MAV_RESULT_FAILED;
|
||||
}
|
||||
#if AP_PLANE_OFFBOARD_GUIDED_SLEW_ENABLED
|
||||
plane.guided_state.target_heading_type = GUIDED_HEADING_NONE;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user