mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-06 06:43:21 +08:00
prevent double-precision promotion where its not required
This commit is contained in:
@@ -155,8 +155,8 @@ __EXPORT float pid_calculate(PID_t *pid, float sp, float val, float val_dot, flo
|
|||||||
// Calculate the error integral and check for saturation
|
// Calculate the error integral and check for saturation
|
||||||
i = pid->integral + (error * dt);
|
i = pid->integral + (error * dt);
|
||||||
|
|
||||||
if (fabs((error * pid->kp) + (i * pid->ki) + (d * pid->kd)) > pid->limit ||
|
if (fabsf((error * pid->kp) + (i * pid->ki) + (d * pid->kd)) > pid->limit ||
|
||||||
fabs(i) > pid->intmax) {
|
fabsf(i) > pid->intmax) {
|
||||||
i = pid->integral; // If saturated then do not update integral value
|
i = pid->integral; // If saturated then do not update integral value
|
||||||
pid->saturated = 1;
|
pid->saturated = 1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user