mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 02:51:37 +08:00
fix commander: set _have_taken_off_since_arming when !landed upon arming
If arming and already !landed, _have_taken_off_since_arming will not be set and thus auto-disarm after 10s will be triggered (with default config). This can only happen due to quick state changes, as land detector generally sets landed=true if !armed.
This commit is contained in:
@@ -2189,7 +2189,12 @@ Commander::run()
|
|||||||
if (_was_armed != armed.armed) {
|
if (_was_armed != armed.armed) {
|
||||||
_status_changed = true;
|
_status_changed = true;
|
||||||
|
|
||||||
if (!armed.armed) { // increase the flight uuid upon disarming
|
if (armed.armed) {
|
||||||
|
if (!_land_detector.landed) { // check if takeoff already detected upon arming
|
||||||
|
_have_taken_off_since_arming = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { // increase the flight uuid upon disarming
|
||||||
const int32_t flight_uuid = _param_flight_uuid.get() + 1;
|
const int32_t flight_uuid = _param_flight_uuid.get() + 1;
|
||||||
_param_flight_uuid.set(flight_uuid);
|
_param_flight_uuid.set(flight_uuid);
|
||||||
_param_flight_uuid.commit_no_notification();
|
_param_flight_uuid.commit_no_notification();
|
||||||
@@ -2198,6 +2203,11 @@ Commander::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!armed.armed) {
|
||||||
|
/* Reset the flag if disarmed. */
|
||||||
|
_have_taken_off_since_arming = false;
|
||||||
|
}
|
||||||
|
|
||||||
_was_armed = armed.armed;
|
_was_armed = armed.armed;
|
||||||
|
|
||||||
/* now set navigation state according to failsafe and main state */
|
/* now set navigation state according to failsafe and main state */
|
||||||
@@ -2359,11 +2369,6 @@ Commander::run()
|
|||||||
|
|
||||||
_status_changed = false;
|
_status_changed = false;
|
||||||
|
|
||||||
if (!armed.armed) {
|
|
||||||
/* Reset the flag if disarmed. */
|
|
||||||
_have_taken_off_since_arming = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
arm_auth_update(now, params_updated || param_init_forced);
|
arm_auth_update(now, params_updated || param_init_forced);
|
||||||
|
|
||||||
px4_usleep(COMMANDER_MONITORING_INTERVAL);
|
px4_usleep(COMMANDER_MONITORING_INTERVAL);
|
||||||
|
|||||||
Reference in New Issue
Block a user