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:
Beat Küng 2020-04-03 11:48:43 +02:00 committed by Julian Oes
parent 8709fc3cf9
commit aa6f9280e1
1 changed files with 11 additions and 6 deletions

View File

@ -2189,7 +2189,12 @@ Commander::run()
if (_was_armed != armed.armed) {
_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;
_param_flight_uuid.set(flight_uuid);
_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;
/* now set navigation state according to failsafe and main state */
@ -2359,11 +2369,6 @@ Commander::run()
_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);
px4_usleep(COMMANDER_MONITORING_INTERVAL);