Reset ITerm after crash

This commit is contained in:
Martin Budden 2017-08-23 07:22:13 +01:00
parent d031b038eb
commit 3bae1e78e2
1 changed files with 3 additions and 0 deletions

View File

@ -422,6 +422,9 @@ void pidController(const pidProfile_t *pidProfile, const rollAndPitchTrims_t *an
errorRate = currentPidSetpoint - gyroRate;
}
}
// reset ITerm, since accumulated error before crash is now meaningless
// and ITerm windup during crash recovery can be extreme, especially on yaw axis
axisPID_I[axis] = 0.0f;
if (cmpTimeUs(currentTimeUs, crashDetectedAtUs) > crashTimeLimitUs
|| (motorMixRange < 1.0f
&& ABS(gyro.gyroADCf[FD_ROLL]) < crashRecoveryRate