diff --git a/libraries/AC_PID/AC_PID.h b/libraries/AC_PID/AC_PID.h index c3a968dda9..cd291a02fc 100644 --- a/libraries/AC_PID/AC_PID.h +++ b/libraries/AC_PID/AC_PID.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #define AC_PID_TFILT_HZ_DEFAULT 0.0f // default input filter frequency @@ -15,6 +14,8 @@ #define AC_PID_DFILT_HZ_DEFAULT 20.0f // default input filter frequency #define AC_PID_RESET_TC 0.16f // Time constant for integrator reset decay to zero +#include "AP_PIDInfo.h" + /// @class AC_PID /// @brief Copter PID control class class AC_PID { @@ -116,7 +117,7 @@ public: // return current slew rate of slew limiter. Will return 0 if SMAX is zero float get_slew_rate(void) const { return _slew_limiter.get_slew_rate(); } - const AP_Logger::PID_Info& get_pid_info(void) const { return _pid_info; } + const AP_PIDInfo& get_pid_info(void) const { return _pid_info; } // parameter var table static const struct AP_Param::GroupInfo var_info[]; @@ -155,5 +156,5 @@ protected: float _derivative; // derivative value to enable filtering int8_t _slew_limit_scale; - AP_Logger::PID_Info _pid_info; + AP_PIDInfo _pid_info; }; diff --git a/libraries/AC_PID/AC_PID_2D.h b/libraries/AC_PID/AC_PID_2D.h index 7f17d534fe..6e18340048 100644 --- a/libraries/AC_PID/AC_PID_2D.h +++ b/libraries/AC_PID/AC_PID_2D.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include /// @class AC_PID_2D /// @brief Copter PID control class @@ -75,8 +75,8 @@ public: void set_integrator(const Vector3f& i) { set_integrator(Vector2f{i.x, i.y}); } void set_integrator(const Vector2f& i); - const AP_Logger::PID_Info& get_pid_info_x(void) const { return _pid_info_x; } - const AP_Logger::PID_Info& get_pid_info_y(void) const { return _pid_info_y; } + const AP_PIDInfo& get_pid_info_x(void) const { return _pid_info_x; } + const AP_PIDInfo& get_pid_info_y(void) const { return _pid_info_y; } // parameter var table static const struct AP_Param::GroupInfo var_info[]; @@ -100,6 +100,6 @@ protected: Vector2f _integrator; // integrator value bool _reset_filter; // true when input filter should be reset during next call to update_all - AP_Logger::PID_Info _pid_info_x; - AP_Logger::PID_Info _pid_info_y; + AP_PIDInfo _pid_info_x; + AP_PIDInfo _pid_info_y; }; diff --git a/libraries/AC_PID/AC_PID_Basic.h b/libraries/AC_PID/AC_PID_Basic.h index 65143a26a2..8ab1f6f100 100644 --- a/libraries/AC_PID/AC_PID_Basic.h +++ b/libraries/AC_PID/AC_PID_Basic.h @@ -5,7 +5,7 @@ #include #include -#include +#include "AP_PIDInfo.h" /// @class AC_PID_Basic /// @brief Copter PID control class @@ -70,7 +70,7 @@ public: void set_integrator(float error, float i); void set_integrator(float i); - const AP_Logger::PID_Info& get_pid_info(void) const WARN_IF_UNUSED { return _pid_info; } + const AP_PIDInfo& get_pid_info(void) const WARN_IF_UNUSED { return _pid_info; } // parameter var table static const struct AP_Param::GroupInfo var_info[]; @@ -94,5 +94,5 @@ protected: float _integrator; // integrator value bool _reset_filter; // true when input filter should be reset during next call to set_input - AP_Logger::PID_Info _pid_info; + AP_PIDInfo _pid_info; }; diff --git a/libraries/AC_PID/AP_PIDInfo.h b/libraries/AC_PID/AP_PIDInfo.h new file mode 100644 index 0000000000..98a05f879d --- /dev/null +++ b/libraries/AC_PID/AP_PIDInfo.h @@ -0,0 +1,20 @@ +#pragma once + +// This structure provides information on the internal member data of +// a PID. It provides an abstract way to pass PID information around, +// useful for logging and sending mavlink messages. + +// It is also used to pass PID information into controllers... + +struct AP_PIDInfo { + float target; + float actual; + float error; + float P; + float I; + float D; + float FF; + float Dmod; + float slew_rate; + bool limit; +};