AP_Terrain: avoid direct use of Location alt field

This commit is contained in:
Peter Barker 2022-01-29 20:48:28 +11:00 committed by Andrew Tridgell
parent d24612b4ac
commit 5fe91f16af
1 changed files with 3 additions and 5 deletions

View File

@ -247,11 +247,9 @@ void AP_Terrain::send_terrain_report(mavlink_channel_t chan, const Location &loc
if (spacing == 0 && !(extrapolate && have_current_loc_height)) {
current_height = 0;
} else {
if (current_loc.relative_alt) {
current_height = current_loc.alt*0.01f;
} else {
current_height = (current_loc.alt - ahrs.get_home().alt)*0.01f;
}
int32_t height_above_home_cm = 0;
UNUSED_RESULT(current_loc.get_alt_cm(Location::AltFrame::ABOVE_HOME, height_above_home_cm));
current_height = height_above_home_cm * 0.01f; // cm -> m
}
current_height += home_terrain_height - terrain_height;