diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index 752121c886..4bdc9190f8 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -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);