Browse Source

AC_Avoid: add singleton

mission-4.1.18
Peter Barker 6 years ago committed by Peter Barker
parent
commit
413ef5a3b4
  1. 14
      libraries/AC_Avoidance/AC_Avoid.cpp
  2. 11
      libraries/AC_Avoidance/AC_Avoid.h

14
libraries/AC_Avoidance/AC_Avoid.cpp

@ -57,6 +57,8 @@ AC_Avoid::AC_Avoid(const AP_AHRS& ahrs, const AC_Fence& fence, const AP_Proximit @@ -57,6 +57,8 @@ AC_Avoid::AC_Avoid(const AP_AHRS& ahrs, const AC_Fence& fence, const AP_Proximit
_proximity(proximity),
_beacon(beacon)
{
_singleton = this;
AP_Param::setup_object_defaults(this, var_info);
}
@ -571,3 +573,15 @@ void AC_Avoid::get_proximity_roll_pitch_pct(float &roll_positive, float &roll_ne @@ -571,3 +573,15 @@ void AC_Avoid::get_proximity_roll_pitch_pct(float &roll_positive, float &roll_ne
}
}
}
// singleton instance
AC_Avoid *AC_Avoid::_singleton;
namespace AP {
AC_Avoid *ac_avoid()
{
return AC_Avoid::get_singleton();
}
}

11
libraries/AC_Avoidance/AC_Avoid.h

@ -34,6 +34,11 @@ public: @@ -34,6 +34,11 @@ public:
AC_Avoid(const AC_Avoid &other) = delete;
AC_Avoid &operator=(const AC_Avoid&) = delete;
// get singleton instance
static AC_Avoid *get_singleton() {
return _singleton;
}
/*
* Adjusts the desired velocity so that the vehicle can stop
* before the fence/object.
@ -140,4 +145,10 @@ private: @@ -140,4 +145,10 @@ private:
AP_Int8 _behavior; // avoidance behaviour (slide or stop)
bool _proximity_enabled = true; // true if proximity sensor based avoidance is enabled (used to allow pilot to enable/disable)
static AC_Avoid *_singleton;
};
namespace AP {
AC_Avoid *ac_avoid();
};

Loading…
Cancel
Save