21 set_param(dt_, Kp_, Ki_, Kd_, fc_, u_k_1_, u_k_2_, u_max_);
32 tau = 1.0 / (6.28318530717958647692528676655900576 * fc_);
44 if ((start == 0) || (start == 1))
47 u_k = u_ff + u_k_1 + Kp * e_k;
51 u_k = u_ff + (-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);
105 tau = 1.0 / (6.28318530717958647692528676655900576 * fc_);
153 return 1.0 / (6.28318530717958647692528676655900576 * tau);
void set_u_0(T u_k_1_)
Sets the previous controller output.
T get_fc()
Gets the derivative filter cutoff frequency.
T get_u_max()
Gets the maximum controller output.
PID_LPF_1_FF()
Constructs a PID controller with filtered derivative and feed-forward support.
void set_Kd(T Kd_)
Sets the derivative gain.
T get_u_k_1()
Gets the previous controller output.
void set_dt(T dt_)
Sets the controller sampling time.
void set_ff(T u_ff_)
Sets the feed-forward control input.
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_fc(T fc_)
Sets the derivative filter cutoff frequency.
T get_e_k_1()
Gets the previous control error.
void reset()
Resets the PID controller state.
void set_Ki(T Ki_)
Sets the integral gain.
T get_e_k_2()
Gets the control error from two iterations ago.
void set_u_max(T u_max_)
Sets the maximum controller output.
T get_Kd()
Gets the derivative gain.
T get_Ki()
Gets the integral gain.
T get_dt()
Gets the controller sampling time.
void merge(T u_k_1_)
Merges an external controller output into the PID state.
void set_Kp(T Kp_)
Sets the proportional gain.
T update(T x_0, T x, T u_ff_=0.0)
Computes the PID control output with feed-forward.
T get_ff()
Gets the feed-forward control input.
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.
T get_Kp()
Gets the proportional gain.
PID controller with first-order low-pass filtered derivative and feed-forward.
constexpr T saturate(T x, T x_min, T x_max)
Saturates a value within a specified range.