1
0
Fork 0
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:
Konstantin Sharlaimov (DigitalEntity) 2016-04-10 21:54:59 +10:00
parent a9a1f84b41
commit e5726c3c35

View file

@ -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;