Skip to content

Commit

Permalink
Sub: set inFlight to true if sub descends or rangefinder value decreases
Browse files Browse the repository at this point in the history
  • Loading branch information
clydemcqueen committed Apr 11, 2024
1 parent a6d2cb9 commit a94ebae
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libraries/AP_NavEKF3/AP_NavEKF3_VehicleStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,17 @@ void NavEKF3_core::detectFlight()
}

if (!onGround) {
#if APM_BUILD_TYPE(APM_BUILD_ArduSub)
// If depth has increased since arming, then we definitely are diving
if ((stateStruct.position.z - posDownAtTakeoff) > 1.5f) {
inFlight = true;
}

// If rangefinder has decreased since since arming, then we definitely are diving
if ((rangeDataNew.rng - rngAtStartOfFlight) < -0.5f) {
inFlight = true;
}
#else
// If height has increased since exiting on-ground, then we definitely are flying
if ((stateStruct.position.z - posDownAtTakeoff) < -1.5f) {
inFlight = true;
Expand All @@ -388,14 +399,14 @@ void NavEKF3_core::detectFlight()
if ((rangeDataNew.rng - rngAtStartOfFlight) > 0.5f) {
inFlight = true;
}
#endif

// If more than 5 seconds since likely_flying was set
// true, then set inFlight true
if (dal.get_time_flying_ms() > 5000) {
inFlight = true;
}
}

}

// Store vehicle height and range prior to takeoff for use in post takeoff checks
Expand Down

0 comments on commit a94ebae

Please sign in to comment.