AP_Rally: tidy creation of Location from RallyLocation

This commit is contained in:
Peter Barker 2022-07-01 11:16:06 +10:00 committed by Peter Barker
parent 591f43e7d0
commit da2b530ce8
1 changed files with 10 additions and 11 deletions

View File

@ -122,18 +122,17 @@ bool AP_Rally::set_rally_point_with_index(uint8_t i, const RallyLocation &rallyL
// helper function to translate a RallyLocation to a Location
Location AP_Rally::rally_location_to_location(const RallyLocation &rally_loc) const
{
Location ret = {};
//Relative altitudes are relative to HOME point's altitude:
Location ret {
rally_loc.lat,
rally_loc.lng,
rally_loc.alt * 100,
Location::AltFrame::ABOVE_HOME
};
// we return an absolute altitude, as we add homeloc.alt below
ret.relative_alt = false;
//Currently can't do true AGL on the APM. Relative altitudes are
//relative to HOME point's altitude. Terrain on the board is inbound
//for the PX4, though. This line will need to be updated when that happens:
ret.alt = (rally_loc.alt*100UL) + AP::ahrs().get_home().alt;
ret.lat = rally_loc.lat;
ret.lng = rally_loc.lng;
// notionally the following call can fail, but we have no facility
// to return that fact here:
ret.change_alt_frame(Location::AltFrame::ABSOLUTE);
return ret;
}