mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 03:00:36 +08:00
ManualControl: fix case where mode switches unintentionally in air
Case: A vehicle is already operating but has no stick input or another source than RC. When RC stick input is switched to either because it gets first time available or as a fallback to joystick then the mode was immediately changed to the switch position. This can lead to loss of control e.g. when the vehicle is flying far away and the mode switch of the RC is in some fully manual piloted mode. I added tests to cover the cases where RC mode initialization is expected and also unexpceted because the vehicle is already armed.
This commit is contained in:
@@ -81,6 +81,7 @@ void ManualControl::processInput(hrt_abstime now)
|
||||
vehicle_status_s vehicle_status;
|
||||
|
||||
if (_vehicle_status_sub.copy(&vehicle_status)) {
|
||||
_armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
|
||||
_system_id = vehicle_status.system_id;
|
||||
_rotary_wing = (vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING);
|
||||
_vtol = vehicle_status.is_vtol;
|
||||
@@ -269,8 +270,8 @@ void ManualControl::processSwitches(hrt_abstime &now)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Send an initial request to switch to the mode requested by RC
|
||||
} else if (!_armed) {
|
||||
// Directly initialize mode using RC switch but only before arming
|
||||
evaluateModeSlot(switches.mode_slot);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user