Skip to content

Commit

Permalink
AP_Common: add get_alt - 100 times better than get_alt_cm
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Apr 16, 2024
1 parent 423198c commit 44359ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libraries/AP_Common/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ bool Location::get_alt_cm(AltFrame desired_frame, int32_t &ret_alt_cm) const
}
return false; // LCOV_EXCL_LINE - not reachable
}
bool Location::get_alt_m(AltFrame desired_frame, float &ret_alt) const
{
int32_t ret_alt_cm;
if (!get_alt_cm(desired_frame, ret_alt_cm)) {
return false;
}
ret_alt = ret_alt_cm * 0.01;
return true;
}

#if AP_AHRS_ENABLED
bool Location::get_vector_xy_from_origin_NE(Vector2f &vec_ne) const
Expand Down
2 changes: 2 additions & 0 deletions libraries/AP_Common/Location.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Location
// - above-home and home is not set
// - above-origin and origin is not set
bool get_alt_cm(AltFrame desired_frame, int32_t &ret_alt_cm) const WARN_IF_UNUSED;
// same as get_alt_cm but in metres:
bool get_alt_m(AltFrame desired_frame, float &ret_alt) const WARN_IF_UNUSED;

// get altitude frame
AltFrame get_alt_frame() const;
Expand Down

0 comments on commit 44359ff

Please sign in to comment.