Plane: fix rangefinder correction when terrain follow is off

This commit is contained in:
Jonathan Challinger 2023-05-02 07:45:59 +10:00 committed by Randy Mackay
parent be5fa49c98
commit 392c563a04
1 changed files with 2 additions and 3 deletions

View File

@ -711,9 +711,8 @@ void Plane::rangefinder_height_update(void)
}
if (rangefinder_state.in_range) {
// base correction is the difference between baro altitude and
// rangefinder estimate
float correction = adjusted_relative_altitude_cm()*0.01 - rangefinder_state.height_estimate;
// If not using terrain data, we expect zero correction when our height above target is equal to our rangefinder measurement
float correction = height_above_target() - rangefinder_state.height_estimate;
#if AP_TERRAIN_AVAILABLE
// if we are terrain following then correction is based on terrain data