Browse Source

AP_Common: add initialised() method to Location

Sometimes code paths are crossed when they shouldn't be.  This method
can help in the short term if a codepath is calling methods on a
Location when it is not initialised, but generally a vehicle should be
calling position_ok() and other methods rather than this one.
master
Peter Barker 6 years ago committed by Randy Mackay
parent
commit
4e5842a150
  1. 2
      libraries/AP_Common/Location.cpp
  2. 2
      libraries/AP_Common/Location.h

2
libraries/AP_Common/Location.cpp

@ -103,7 +103,7 @@ Location::AltFrame Location::get_alt_frame() const @@ -103,7 +103,7 @@ Location::AltFrame Location::get_alt_frame() const
bool Location::get_alt_cm(AltFrame desired_frame, int32_t &ret_alt_cm) const
{
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
if (lat == 0 && lng == 0) {
if (!initialised()) {
AP_HAL::panic("Should not be called on invalid location");
}
#endif

2
libraries/AP_Common/Location.h

@ -112,6 +112,8 @@ public: @@ -112,6 +112,8 @@ public:
*/
float line_path_proportion(const Location &point1, const Location &point2) const;
bool initialised() const { return (lat !=0 || lng != 0); }
private:
static AP_Terrain *_terrain;

Loading…
Cancel
Save