1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-19 09:54:15 +01:00

PID: Fix small bug in setpoint weighting that had really ugly consequences

This commit is contained in:
James Cotton 2012-09-12 00:07:17 -05:00
parent f9fd2bd1af
commit 595083c982

View File

@ -88,9 +88,9 @@ float pid_apply_setpoint(struct pid *pid, const float setpoint, const float meas
pid->iAccumulator = bound(pid->iAccumulator, pid->iLim * 1000.0f);
// Calculate DT1 term,
float diff = ((deriv_gamma * setpoint - measured) - pid->lastErr);
float dterm = 0;
pid->lastErr = err;
float diff = ((deriv_gamma * setpoint - measured) - pid->lastErr);
pid->lastErr = (deriv_gamma * setpoint - measured);
if(pid->d && dT)
{
dterm = pid->lastDer + dT / ( dT + deriv_tau) * ((diff * pid->d / dT) - pid->lastDer);