33 #ifndef CONTROL_TOOLBOX__PID_HPP_
34 #define CONTROL_TOOLBOX__PID_HPP_
39 #include "rclcpp/clock.hpp"
40 #include "rclcpp/duration.hpp"
41 #include "rclcpp/node.hpp"
43 #include "realtime_tools/realtime_buffer.h"
44 #include "realtime_tools/realtime_publisher.h"
46 #include "control_toolbox/visibility_control.hpp"
108 class CONTROL_TOOLBOX_PUBLIC
Pid
127 Gains(
double p,
double i,
double d,
double i_max,
double i_min)
128 : p_gain_(p), i_gain_(i), d_gain_(d), i_max_(i_max), i_min_(i_min), antiwindup_(true)
144 Gains(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup)
145 : p_gain_(p), i_gain_(i), d_gain_(d), i_max_(i_max), i_min_(i_min), antiwindup_(antiwindup)
149 Gains() : p_gain_(0.0), i_gain_(0.0), d_gain_(0.0), i_max_(0.0), i_min_(0.0), antiwindup_(false)
175 double p = 0.0,
double i = 0.0,
double d = 0.0,
double i_max = 0.0,
double i_min = -0.0,
176 bool antiwindup =
false);
202 void initPid(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup =
false);
217 void getGains(
double & p,
double & i,
double & d,
double & i_max,
double & i_min);
228 double & p,
double & i,
double & d,
double & i_max,
double & i_min,
bool & antiwindup);
247 void setGains(
double p,
double i,
double d,
double i_max,
double i_min,
bool antiwindup =
false);
255 void setGains(
const Gains & gains);
267 [[nodiscard]]
double computeCommand(
double error, uint64_t dt);
280 [[nodiscard]]
double computeCommand(
double error,
double error_dot, uint64_t dt);
285 void setCurrentCmd(
double cmd);
290 double getCurrentCmd();
295 double getDerivativeError();
303 void getCurrentPIDErrors(
double & pe,
double & ie,
double & de);
311 if (
this == &source) {
316 gains_buffer_ = source.gains_buffer_;