Browse Source

AP_Rally: tidy creation of Location from RallyLocation

apm_2208
Peter Barker 3 years ago committed by Peter Barker
parent
commit
da2b530ce8
  1. 21
      libraries/AP_Rally/AP_Rally.cpp

21
libraries/AP_Rally/AP_Rally.cpp

@ -122,18 +122,17 @@ bool AP_Rally::set_rally_point_with_index(uint8_t i, const RallyLocation &rallyL @@ -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 = {};
// 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;
//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
};
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;
}

Loading…
Cancel
Save