From e05c7b3367867c12f6f8d9496b5087b0343a48aa Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 10 Jun 2016 17:47:32 +1000 Subject: [PATCH] Plane: check if terrain following is enabled in AGL calculation --- ArduPlane/altitude.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ArduPlane/altitude.cpp b/ArduPlane/altitude.cpp index 05cff9d781..5f47316030 100644 --- a/ArduPlane/altitude.cpp +++ b/ArduPlane/altitude.cpp @@ -145,7 +145,9 @@ float Plane::relative_ground_altitude(bool use_rangefinder_if_available) #if AP_TERRAIN_AVAILABLE float altitude; - if (terrain.status() == AP_Terrain::TerrainStatusOK && terrain.height_above_terrain(altitude, true)) { + if (target_altitude.terrain_following && + terrain.status() == AP_Terrain::TerrainStatusOK && + terrain.height_above_terrain(altitude, true)) { return altitude; } #endif