diff --git a/libraries/AP_NavEKF2/AP_NavEKF2_VehicleStatus.cpp b/libraries/AP_NavEKF2/AP_NavEKF2_VehicleStatus.cpp index 2bcdf39510..e88ea66c7b 100644 --- a/libraries/AP_NavEKF2/AP_NavEKF2_VehicleStatus.cpp +++ b/libraries/AP_NavEKF2/AP_NavEKF2_VehicleStatus.cpp @@ -357,14 +357,22 @@ void NavEKF2_core::detectFlight() onGround = true; } - // If height has increased since exiting on-ground, then we definitely are flying - if (!onGround && ((stateStruct.position.z - posDownAtTakeoff) < -1.5f)) { - inFlight = true; - } + if (!onGround) { + // If height has increased since exiting on-ground, then we definitely are flying + if ((stateStruct.position.z - posDownAtTakeoff) < -1.5f) { + inFlight = true; + } + + // If rangefinder has increased since exiting on-ground, then we definitely are flying + if ((rangeDataNew.rng - rngAtStartOfFlight) > 0.5f) { + inFlight = true; + } + + // If more than 15 seconds armed since exiting on-ground, then we definitely are flying + if ((imuSampleTime_ms - timeAtArming_ms) > 15000) { + inFlight = true; + } - // If rangefinder has increased since exiting on-ground, then we definitely are flying - if (!onGround && ((rangeDataNew.rng - rngAtStartOfFlight) > 0.5f)) { - inFlight = true; } }