From 8169910866697068410e83ee50d09bfb83826d07 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 20 Aug 2021 12:20:59 +1000 Subject: [PATCH] AP_AHRS: move frontend parameters up / DCM parameters down --- libraries/AP_AHRS/AP_AHRS.h | 19 +++++++++++++++++++ libraries/AP_AHRS/AP_AHRS_Backend.h | 16 ---------------- libraries/AP_AHRS/AP_AHRS_DCM.cpp | 1 + 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/libraries/AP_AHRS/AP_AHRS.h b/libraries/AP_AHRS/AP_AHRS.h index 6d6613bf20..2258fa4e0d 100644 --- a/libraries/AP_AHRS/AP_AHRS.h +++ b/libraries/AP_AHRS/AP_AHRS.h @@ -116,6 +116,10 @@ public: // return a wind estimation vector, in m/s Vector3f wind_estimate() const override; + // return the parameter AHRS_WIND_MAX in metres per second + uint8_t get_max_wind() const { + return _wind_max; + } /* * airspeed support @@ -335,6 +339,11 @@ public: return uint8_t(active_EKF_type()); } + // get the selected ekf type, for allocation decisions + int8_t get_ekf_type(void) const { + return _ekf_type; + } + // these are only out here so vehicles can reference them for parameters #if HAL_NAVEKF2_AVAILABLE NavEKF2 EKF2; @@ -466,6 +475,16 @@ private: */ VehicleClass _vehicle_class{VehicleClass::UNKNOWN}; + /* + * Parameters + */ + AP_Int8 _wind_max; + AP_Int8 _board_orientation; + AP_Int8 _ekf_type; + AP_Float _custom_roll; + AP_Float _custom_pitch; + AP_Float _custom_yaw; + enum class EKFType { NONE = 0 #if HAL_NAVEKF3_AVAILABLE diff --git a/libraries/AP_AHRS/AP_AHRS_Backend.h b/libraries/AP_AHRS/AP_AHRS_Backend.h index 9b74bde96a..701da0b9b9 100644 --- a/libraries/AP_AHRS/AP_AHRS_Backend.h +++ b/libraries/AP_AHRS/AP_AHRS_Backend.h @@ -206,11 +206,6 @@ public: return _airspeed != nullptr && _airspeed->use(airspeed_index) && _airspeed->healthy(airspeed_index); } - // return the parameter AHRS_WIND_MAX in metres per second - uint8_t get_max_wind() const { - return _wind_max; - } - // return a ground vector estimate in meters/second, in North/East order virtual Vector2f groundspeed_vector(void); @@ -374,11 +369,6 @@ public: return false; } - // get the selected ekf type, for allocation decisions - int8_t get_ekf_type(void) const { - return _ekf_type; - } - // Retrieves the corrected NED delta velocity in use by the inertial navigation virtual void getCorrectedDeltaVelocityNED(Vector3f& ret, float& dt) const { ret.zero(); @@ -455,13 +445,7 @@ protected: }; AP_Enum _gps_use; - AP_Int8 _wind_max; - AP_Int8 _board_orientation; AP_Int8 _gps_minsats; - AP_Int8 _ekf_type; - AP_Float _custom_roll; - AP_Float _custom_pitch; - AP_Float _custom_yaw; Matrix3f _custom_rotation; diff --git a/libraries/AP_AHRS/AP_AHRS_DCM.cpp b/libraries/AP_AHRS/AP_AHRS_DCM.cpp index f51d31e316..91490d3540 100644 --- a/libraries/AP_AHRS/AP_AHRS_DCM.cpp +++ b/libraries/AP_AHRS/AP_AHRS_DCM.cpp @@ -1091,6 +1091,7 @@ bool AP_AHRS_DCM::airspeed_estimate(uint8_t airspeed_index, float &airspeed_ret) return false; } + const float _wind_max = AP::ahrs().get_max_wind(); if (_wind_max > 0 && AP::gps().status() >= AP_GPS::GPS_OK_FIX_2D) { // constrain the airspeed by the ground speed // and AHRS_WIND_MAX