Skip to content

Commit

Permalink
AC_WPNav: simplify get_wp_destination_loc
Browse files Browse the repository at this point in the history
  • Loading branch information
hendjoshsr71 authored and rmackay9 committed Sep 6, 2021
1 parent 0ee8b45 commit a91c0f4
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions libraries/AC_WPNav/AC_WPNav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,15 @@ bool AC_WPNav::set_wp_destination_next_loc(const Location& destination)
return set_wp_destination_next(dest_neu, terr_alt);
}

// get destination as a location. Altitude frame will be absolute (AMSL) or above terrain
// get destination as a location. Altitude frame will be above origin or above terrain
// returns false if unable to return a destination (for example if origin has not yet been set)
bool AC_WPNav::get_wp_destination_loc(Location& destination) const
{
if (!AP::ahrs().get_origin(destination)) {
return false;
}
destination.offset(_destination.x*0.01f, _destination.y*0.01f);
if (_terrain_alt) {
destination.set_alt_cm(_destination.z, Location::AltFrame::ABOVE_TERRAIN);
} else {
destination.alt += _destination.z;
}

destination = Location{get_wp_destination(), _terrain_alt ? Location::AltFrame::ABOVE_TERRAIN : Location::AltFrame::ABOVE_ORIGIN};
return true;
}

Expand Down

0 comments on commit a91c0f4

Please sign in to comment.