Plane: check if terrain following is enabled in AGL calculation

This commit is contained in:
Andrew Tridgell 2016-06-10 17:47:32 +10:00
parent 19834c12e2
commit e05c7b3367
1 changed files with 3 additions and 1 deletions

View File

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