18 set_param(dt_, Kp_, Kd_, fc_, u_max_);
28 tau = 1.0 / (6.28318530717958647692528676655900576 * fc_);
44 u_k = (tau * u_k_1 + (Kp * (dt + tau) + Kd) * e_k - (Kp * tau + Kd) * e_k_1) / (tau + dt);
86 tau = 1.0 / (6.28318530717958647692528676655900576 * fc_);
116 return 1.0 / (6.28318530717958647692528676655900576 * tau);
T get_fc()
Gets the derivative filter cutoff frequency.
PD_LPF_1()
Constructs a PD controller with filtered derivative.
void set_fc(T fc_)
Sets the derivative filter cutoff frequency.
void merge(T u_k_1_)
Merges an external controller output into the PD state.
void set_param(T dt_, T Kp_, T Kd_, T fc_, T u_max_)
Sets the PD controller parameters.
T get_Kp()
Gets the proportional gain.
T get_u_k_1()
Gets the previous controller output.
T get_e_k_1()
Gets the previous control error.
void set_u_max(T u_max_)
Sets the maximum controller output.
T get_u_max()
Gets the maximum controller output.
void set_Kd(T Kd_)
Sets the derivative gain.
T get_Kd()
Gets the derivative gain.
void set_dt(T dt_)
Sets the controller sampling time.
void init(T dt_, T Kp_, T Kd_, T fc_, T u_max_)
Initializes the PD controller.
T update(T x_0, T x)
Computes the PD control output.
void reset()
Resets the PD controller state.
void set_Kp(T Kp_)
Sets the proportional gain.
T get_dt()
Gets the controller sampling time.
Proportional-Derivative (PD) controller with first-order low-pass filtering.
constexpr T saturate(T x, T x_min, T x_max)
Saturates a value within a specified range.