19 set_param(dt_, Kp_, Ki_, Kd_, u_k_1_, u_max_);
39 if ((start == 0) || (start == 1))
42 u_k = u_k_1 + Kp * e_k;
46 u_k = u_k_1 + (Kp + Ki * dt + Kd / dt) * e_k - (Kp + 2.0 * Kd / dt) * e_k_1 + (Kd / dt) * e_k_2;
void merge(T u_k_1_)
Merges an external controller output into the PID state.
void set_dt(T dt_)
Sets the controller sampling time.
T get_e_k_1()
Gets the previous control error.
T get_Kd()
Gets the derivative gain.
void set_param(T dt_, T Kp_, T Ki_, T Kd_, T u_k_1_, T u_max_)
Sets the PID controller parameters.
void set_u_max(T u_max_)
Sets the maximum controller output.
PID()
Constructs a PID controller.
T get_u_max()
Gets the maximum controller output.
void reset()
Resets the PID controller state.
void init(T dt_, T Kp_, T Ki_, T Kd_, T u_k_1_, T u_max_)
Initializes the PID controller.
void set_Ki(T Ki_)
Sets the integral gain.
T get_Kp()
Gets the proportional gain.
void set_u_0(T u_k_1_)
Sets the previous controller output.
T get_dt()
Gets the controller sampling time.
T get_e_k_2()
Gets the control error from two iterations ago.
T get_u_k_1()
Gets the previous controller output.
T update(T x_0, T x)
Computes the PID control output.
T get_Ki()
Gets the integral gain.
void set_Kp(T Kp_)
Sets the proportional gain.
void set_Kd(T Kd_)
Sets the derivative gain.
Proportional-Integral-Derivative (PID) controller.
constexpr T saturate(T x, T x_min, T x_max)
Saturates a value within a specified range.