From 8d216fbce3fba10bafdfc65e616ce8140c877ede Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Tue, 5 Jul 2022 04:08:55 +0100 Subject: [PATCH] AC_PID: params always use set method --- libraries/AC_PID/AC_P.h | 2 +- libraries/AC_PID/AC_PID.cpp | 18 +++++++++--------- libraries/AC_PID/AC_PI_2D.cpp | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libraries/AC_PID/AC_P.h b/libraries/AC_PID/AC_P.h index 76cb398911..706cf55e9a 100644 --- a/libraries/AC_PID/AC_P.h +++ b/libraries/AC_PID/AC_P.h @@ -54,7 +54,7 @@ public: //@{ /// Overload the function call operator to permit relatively easy initialisation - void operator() (const float p) { _kp = p; } + void operator() (const float p) { _kp.set(p); } // accessors AP_Float &kP() { return _kp; } diff --git a/libraries/AC_PID/AC_PID.cpp b/libraries/AC_PID/AC_PID.cpp index 5f2dfd25c0..a38b811676 100644 --- a/libraries/AC_PID/AC_PID.cpp +++ b/libraries/AC_PID/AC_PID.cpp @@ -282,7 +282,7 @@ void AC_PID::load_gains() _kd.load(); _kff.load(); _kimax.load(); - _kimax = fabsf(_kimax); + _kimax.set(fabsf(_kimax)); _filt_T_hz.load(); _filt_E_hz.load(); _filt_D_hz.load(); @@ -304,14 +304,14 @@ void AC_PID::save_gains() /// Overload the function call operator to permit easy initialisation void AC_PID::operator()(float p_val, float i_val, float d_val, float ff_val, float imax_val, float input_filt_T_hz, float input_filt_E_hz, float input_filt_D_hz, float dt) { - _kp = p_val; - _ki = i_val; - _kd = d_val; - _kff = ff_val; - _kimax = fabsf(imax_val); - _filt_T_hz = input_filt_T_hz; - _filt_E_hz = input_filt_E_hz; - _filt_D_hz = input_filt_D_hz; + _kp.set(p_val); + _ki.set(i_val); + _kd.set(d_val); + _kff.set(ff_val); + _kimax.set(fabsf(imax_val)); + _filt_T_hz.set(input_filt_T_hz); + _filt_E_hz.set(input_filt_E_hz); + _filt_D_hz.set(input_filt_D_hz); _dt = dt; } diff --git a/libraries/AC_PID/AC_PI_2D.cpp b/libraries/AC_PID/AC_PI_2D.cpp index 131abb6383..c4f9865723 100644 --- a/libraries/AC_PID/AC_PI_2D.cpp +++ b/libraries/AC_PID/AC_PI_2D.cpp @@ -60,7 +60,7 @@ void AC_PI_2D::filt_hz(float hz) _filt_hz.set(fabsf(hz)); // sanity check _filt_hz - _filt_hz = MAX(_filt_hz, AC_PI_2D_FILT_HZ_MIN); + _filt_hz.set(MAX(_filt_hz, AC_PI_2D_FILT_HZ_MIN)); // calculate the input filter alpha calc_filt_alpha(); @@ -135,7 +135,7 @@ void AC_PI_2D::load_gains() _kp.load(); _ki.load(); _imax.load(); - _imax = fabsf(_imax); + _imax.set(fabsf(_imax)); _filt_hz.load(); // calculate the input filter alpha @@ -154,10 +154,10 @@ void AC_PI_2D::save_gains() /// Overload the function call operator to permit easy initialisation void AC_PI_2D::operator() (float p, float i, float imaxval, float input_filt_hz, float dt) { - _kp = p; - _ki = i; - _imax = fabsf(imaxval); - _filt_hz = input_filt_hz; + _kp.set(p); + _ki.set(i); + _imax.set(fabsf(imaxval)); + _filt_hz.set(input_filt_hz); _dt = dt; // calculate the input filter alpha calc_filt_alpha();