20 set_param(dt_, Kp_, Ki_, Kd_, fc_, u_k_1_, u_k_2_, u_max_);
31 tau = 1.0 / (6.28318530717958647692528676655900576 * fc_);
42 if ((start == 0) || (start == 1))
45 u_k = u_k_1 + Kp * e_k;
49 u_k = (-tau * u_k_2 + (2.0 * tau + dt) * u_k_1 + ((Kp + Ki * dt) * (dt + tau) + Kd) * e_k - (Kp * (2.0 * tau + dt) + Ki * dt * tau + 2.0 * Kd) * e_k_1 + (tau + Kd) * e_k_2) / (dt + tau);
102 tau = 1.0 / (6.28318530717958647692528676655900576 * fc_);
144 return 1.0 / (6.28318530717958647692528676655900576 * tau);
void init(T dt_, T Kp_, T Ki_, T Kd_, T fc_, T u_k_1_, T u_k_2_, T u_max_)
Initializes the PID controller.
void set_u_0(T u_k_1_)
Sets the previous controller output.
void set_Ki(T Ki_)
Sets the integral gain.
T get_Ki()
Gets the integral gain.
void merge(T u_k_1_)
Merges an external controller output into the PID state.
T get_e_k_2()
Gets the control error from two iterations ago.
void set_Kd(T Kd_)
Sets the derivative gain.
T get_fc()
Gets the derivative filter cutoff frequency.
void set_dt(T dt_)
Sets the controller sampling time.
T update(T x_0, T x)
Computes the PID control output.
void reset()
Resets the PID controller state.
T get_u_max()
Gets the maximum controller output.
T get_Kp()
Gets the proportional gain.
T get_u_k_1()
Gets the previous controller output.
PID_LPF_1()
Constructs a PID controller with filtered derivative.
void set_fc(T fc_)
Sets the derivative filter cutoff frequency.
void set_Kp(T Kp_)
Sets the proportional gain.
T get_dt()
Gets the controller sampling time.
void set_param(T dt_, T Kp_, T Ki_, T Kd_, T fc_, T u_k_1_, T u_k_2_, T u_max_)
Sets the PID controller parameters.
void set_u_max(T u_max_)
Sets the maximum controller output.
T get_e_k_1()
Gets the previous control error.
T get_Kd()
Gets the derivative gain.
PID controller with first-order low-pass filtered derivative.
constexpr T saturate(T x, T x_min, T x_max)
Saturates a value within a specified range.