33 #ifndef CONTROL_TOOLBOX__PID_HPP_
34 #define CONTROL_TOOLBOX__PID_HPP_
41 #include "realtime_tools/realtime_buffer.hpp"
43 #include "control_toolbox/visibility_control.hpp"
105 class CONTROL_TOOLBOX_PUBLIC
Pid
124 Gains(
double p,
double i,
double d,
double i_max,
double i_min)
125 : p_gain_(p), i_gain_(i), d_gain_(d), i_max_(i_max), i_min_(i_min), antiwindup_(true)
141 Gains(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup)
142 : p_gain_(p), i_gain_(i), d_gain_(d), i_max_(i_max), i_min_(i_min), antiwindup_(antiwindup)
146 Gains() : p_gain_(0.0), i_gain_(0.0), d_gain_(0.0), i_max_(0.0), i_min_(0.0), antiwindup_(false)
172 double p = 0.0,
double i = 0.0,
double d = 0.0,
double i_max = 0.0,
double i_min = -0.0,
173 bool antiwindup =
false);
199 void initPid(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup =
false);
214 void getGains(
double & p,
double & i,
double & d,
double & i_max,
double & i_min);
225 double & p,
double & i,
double & d,
double & i_max,
double & i_min,
bool & antiwindup);
244 void setGains(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup =
false);
252 void setGains(
const Gains & gains);
264 [[nodiscard]]
double computeCommand(
double error, uint64_t dt);
277 [[nodiscard]]
double computeCommand(
double error,
double error_dot, uint64_t dt);
282 void setCurrentCmd(
double cmd);
287 double getCurrentCmd();
292 double getDerivativeError();
300 void getCurrentPIDErrors(
double & pe,
double & ie,
double & de);
308 if (
this == &source) {
313 gains_buffer_ = source.gains_buffer_;