Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Several forms of PID controllers. More...
Go to the source code of this file.
Data Structures | |
struct | PID_f |
Simple PID structure floating point. More... | |
struct | PID_df |
Distcrete time PID structure. More... | |
struct | PI_D_df |
Distcrete time PI-D structure. More... | |
Functions | |
static void | init_pid_f (struct PID_f *pid, float Kp, float Kd, float Ki, float max_sum) |
static float | update_pid_f (struct PID_f *pid, float value, float dt) |
Update PID with a new value and return new command. More... | |
static float | get_pid_f (struct PID_f *pid) |
Get current value of the PID command. More... | |
static void | reset_pid_f (struct PID_f *pid) |
Reset PID struture, gains left unchanged. More... | |
static void | set_gains_pid_f (struct PID_f *pid, float Kp, float Kd, float Ki) |
Set gains of the PID struct. More... | |
static void | set_integral_pid_f (struct PID_f *pid, float value) |
Set integral part, can be used to reset. More... | |
static void | init_pid_df (struct PID_df *pid, float Kp, float Kd, float Ki, float Ts) |
Init PID struct. More... | |
static float | update_pid_df (struct PID_df *pid, float value) |
Update PID with a new value and return new command. More... | |
static float | get_pid_df (struct PID_df *pid) |
Get current value of the PID command. More... | |
static void | reset_pid_df (struct PID_df *pid) |
Reset PID struture, gains left unchanged. More... | |
static void | set_gains_pid_df (struct PID_df *pid, float Kp, float Kd, float Ki, float Ts) |
Set gains of the PID struct. More... | |
static void | init_pi_d_df (struct PI_D_df *pid, float Kp, float Kd, float Ki, float Ts) |
Init PI-D struct. More... | |
static float | update_pi_d_df (struct PI_D_df *pid, float value, float deriv) |
Update PI-D with a new value and return new command. More... | |
static float | get_pi_d_df (struct PI_D_df *pid) |
Get current value of the PI-D command. More... | |
static void | reset_pi_d_df (struct PI_D_df *pid) |
Reset PI-D struture, gains left unchanged. More... | |
static void | set_gains_pi_d_df (struct PI_D_df *pid, float Kp, float Kd, float Ki, float Ts) |
Set gains PI-D struct. More... | |
Several forms of PID controllers.
Definition in file pid.h.
struct PID_f |
Simple PID structure floating point.
u_k = Kp * e_k + Kd * (e_k - e_k-1) / dt + Ki * (sum (e_k * dt))
with: u = outputs e = inputs Kp = proportional gain Kd = derivative gain Ki = integral gain dt = time since last input
Data Fields | ||
---|---|---|
float | e[2] | input |
float | g[3] | controller gains (Kp, Kd, Ki) |
float | max_sum | windup protection, max of Ki * sum(e_k * dt) |
float | sum | integral of input |
float | u | output |
struct PID_df |
Distcrete time PID structure.
floating point, fixed frequency.
u_k = u_k-1 + a * e_k + b * e_k-1 + c * e_k-2
with: u = outputs e = inputs a = Kp + Ki Ts/2 + Kd/Ts b = -Kp + Ki Ts/2 - 2 Kd/Ts c = Kd/Ts Kp = proportional gain Kd = derivative gain Ki = integral gain Ts = sampling frequency
Data Fields | ||
---|---|---|
float | e[3] | input |
float | g[3] | controller gains |
float | u[2] | output |
struct PI_D_df |
Distcrete time PI-D structure.
derivative term is directly provided as input as it may be available directly from a sensor or estimated separately. floating point, fixed frequency.
u_k = u_k-1 + a * e_k + b * e_k-1 + Kd * d_k
with: u = outputs e = inputs d = derivative of input a = Kp + Ki Ts/2 b = -Kp + Ki Ts/2 Kp = proportional gain Kd = derivative gain Ki = integral gain Ts = sampling frequency
Data Fields | ||
---|---|---|
float | e[2] | input |
float | g[3] | controller gains |
float | u[2] | output |
|
inlinestatic |
Get current value of the PI-D command.
pid | pointer to PI-D structure |
Definition at line 305 of file pid.h.
References PI_D_df::u.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Definition at line 50 of file pid.h.
References PID_f::max_sum.
Referenced by shift_tracking_init().
|
inlinestatic |
Reset PI-D struture, gains left unchanged.
pid | pointer to PI-D structure |
Definition at line 314 of file pid.h.
References PI_D_df::e, and PI_D_df::u.
|
inlinestatic |
|
inlinestatic |
Reset PID struture, gains left unchanged.
pid | pointer to PID structure |
Definition at line 98 of file pid.h.
References PID_f::e, PID_f::sum, and PID_f::u.
Referenced by shift_tracking_reset().
|
inlinestatic |
Set gains PI-D struct.
pid | pointer to PID structure |
Kp | proportional gain |
Kd | derivative gain |
Ki | integral gain |
Ts | sampling time |
Definition at line 330 of file pid.h.
References PI_D_df::g.
|
inlinestatic |
|
inlinestatic |
Set gains of the PID struct.
pid | pointer to PID structure |
Kp | proportional gain |
Kd | derivative gain |
Ki | integral gain |
Definition at line 113 of file pid.h.
References PID_f::g.
Referenced by shift_tracking_update_gains().
|
inlinestatic |
Set integral part, can be used to reset.
The new sum of errors is calculated from current gains and bounds.
pid | pointer to PID structure |
value | integral part of the PID control, 0. will reset it |
Definition at line 126 of file pid.h.
References PID_f::g, PID_f::max_sum, and PID_f::sum.
|
inlinestatic |
Update PI-D with a new value and return new command.
pid | pointer to PI-D structure |
value | new input value of the PI-D |
deriv | new input derivative |
Definition at line 291 of file pid.h.
References PI_D_df::e, PI_D_df::g, and PI_D_df::u.
|
inlinestatic |
|
inlinestatic |
Update PID with a new value and return new command.
pid | pointer to PID structure |
value | new input value of the PID |
dt | time since last input (in seconds) |
Definition at line 68 of file pid.h.
References PID_f::e, PID_f::g, PID_f::max_sum, PID_f::sum, and PID_f::u.
Referenced by shift_tracking_run().