From 7c14a9dd7b3e026a1782daa27e8a4e33f07b89f3 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 11 Apr 2018 21:06:20 +1000 Subject: [PATCH] AC_Sprayer: use ahrs singleton Also remove some unneeded initialisations --- libraries/AC_Sprayer/AC_Sprayer.cpp | 7 ++----- libraries/AC_Sprayer/AC_Sprayer.h | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libraries/AC_Sprayer/AC_Sprayer.cpp b/libraries/AC_Sprayer/AC_Sprayer.cpp index a9f42bb964..afd2677bb4 100644 --- a/libraries/AC_Sprayer/AC_Sprayer.cpp +++ b/libraries/AC_Sprayer/AC_Sprayer.cpp @@ -48,10 +48,7 @@ const AP_Param::GroupInfo AC_Sprayer::var_info[] = { AP_GROUPEND }; -AC_Sprayer::AC_Sprayer(const AP_AHRS_NavEKF &ahrs) : - _ahrs(ahrs), - _speed_over_min_time(0), - _speed_under_min_time(0) +AC_Sprayer::AC_Sprayer() { AP_Param::setup_object_defaults(this, var_info); @@ -107,7 +104,7 @@ void AC_Sprayer::update() // get horizontal velocity Vector3f velocity; - if (!_ahrs.get_velocity_NED(velocity)) { + if (!AP::ahrs().get_velocity_NED(velocity)) { // treat unknown velocity as zero which should lead to pump stopping // velocity will already be zero but this avoids a coverity warning velocity.zero(); diff --git a/libraries/AC_Sprayer/AC_Sprayer.h b/libraries/AC_Sprayer/AC_Sprayer.h index 2849d9d4a9..94f59de075 100644 --- a/libraries/AC_Sprayer/AC_Sprayer.h +++ b/libraries/AC_Sprayer/AC_Sprayer.h @@ -32,7 +32,7 @@ /// @brief Object managing a crop sprayer comprised of a spinner and a pump both controlled by pwm class AC_Sprayer { public: - AC_Sprayer(const AP_AHRS_NavEKF &ahrs); + AC_Sprayer(); /* Do not allow copies */ AC_Sprayer(const AC_Sprayer &other) = delete; @@ -61,7 +61,6 @@ public: static const struct AP_Param::GroupInfo var_info[]; private: - const AP_AHRS_NavEKF &_ahrs; ///< pointers to other objects we depend upon // parameters AP_Int8 _enabled; ///< top level enable/disable control