From 0052dcc8f8bf7bb2492a8ea634673086cc0678f4 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Wed, 16 Oct 2019 17:10:28 +0900 Subject: [PATCH] AC_PID: update pid_info when integrator set --- libraries/AC_PID/AC_PID.cpp | 7 +++++++ libraries/AC_PID/AC_PID.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/AC_PID/AC_PID.cpp b/libraries/AC_PID/AC_PID.cpp index 9275cf2fb5..8ea4a5fb09 100644 --- a/libraries/AC_PID/AC_PID.cpp +++ b/libraries/AC_PID/AC_PID.cpp @@ -327,4 +327,11 @@ void AC_PID::set_integrator(float target, float measurement, float i) void AC_PID::set_integrator(float error, float i) { _integrator = constrain_float(i - error * _kp, -_kimax, _kimax); + _pid_info.I = _integrator; +} + +void AC_PID::set_integrator(float i) +{ + _integrator = constrain_float(i, -_kimax, _kimax); + _pid_info.I = _integrator; } diff --git a/libraries/AC_PID/AC_PID.h b/libraries/AC_PID/AC_PID.h index 2f2529a59e..631eb1c28f 100644 --- a/libraries/AC_PID/AC_PID.h +++ b/libraries/AC_PID/AC_PID.h @@ -101,7 +101,7 @@ public: // integrator setting functions void set_integrator(float target, float measurement, float i); void set_integrator(float error, float i); - void set_integrator(float i) { _integrator = constrain_float(i, -_kimax, _kimax); } + void set_integrator(float i); const AP_Logger::PID_Info& get_pid_info(void) const { return _pid_info; }