mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 16:55:29 +03:00
SURFACE: Better ground level detection. Reset sonar-based ground level each arming. Should make landing detection more reliable
This commit is contained in:
parent
a9a1f84b41
commit
e5726c3c35
1 changed files with 11 additions and 6 deletions
|
@ -1365,14 +1365,19 @@ void updateActualSurfaceDistance(bool hasValidSensor, float surfaceDistance, flo
|
|||
posControl.actualState.surface = surfaceDistance;
|
||||
posControl.actualState.surfaceVel = surfaceVelocity;
|
||||
|
||||
if (surfaceDistance > 0) {
|
||||
if (posControl.actualState.surfaceMin > 0) {
|
||||
posControl.actualState.surfaceMin = MIN(posControl.actualState.surfaceMin, surfaceDistance);
|
||||
}
|
||||
else {
|
||||
posControl.actualState.surfaceMin = surfaceDistance;
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
if (surfaceDistance > 0) {
|
||||
if (posControl.actualState.surfaceMin > 0) {
|
||||
posControl.actualState.surfaceMin = MIN(posControl.actualState.surfaceMin, surfaceDistance);
|
||||
}
|
||||
else {
|
||||
posControl.actualState.surfaceMin = surfaceDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
posControl.actualState.surfaceMin = -1;
|
||||
}
|
||||
|
||||
posControl.flags.hasValidSurfaceSensor = hasValidSensor;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue