Skip to content

Commit 9e08a98

Browse files
jschalltridge
authored andcommitted
Plane: fix rangefinder correction when terrain follow is off
1 parent 44bd77d commit 9e08a98

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ArduPlane/altitude.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,8 @@ void Plane::rangefinder_height_update(void)
711711
}
712712

713713
if (rangefinder_state.in_range) {
714-
// base correction is the difference between baro altitude and
715-
// rangefinder estimate
716-
float correction = adjusted_relative_altitude_cm()*0.01 - rangefinder_state.height_estimate;
714+
// If not using terrain data, we expect zero correction when our height above target is equal to our rangefinder measurement
715+
float correction = height_above_target() - rangefinder_state.height_estimate;
717716

718717
#if AP_TERRAIN_AVAILABLE
719718
// if we are terrain following then correction is based on terrain data

0 commit comments

Comments
 (0)