1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 04:15:44 +03:00

Change iterm_windup to only apply to yaw

Except for when Launch Control is active - then apply to all axes.
This commit is contained in:
Bruce Luckcuck 2020-03-15 13:03:02 -04:00
parent 703519512c
commit e76fd50421
2 changed files with 23 additions and 15 deletions

View file

@ -1452,13 +1452,21 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, timeUs_t currentTim
}
// -----calculate I component
float Ki;
float axisDynCi;
#ifdef USE_LAUNCH_CONTROL
// if launch control is active override the iterm gains
const float Ki = launchControlActive ? launchControlKi : pidCoefficient[axis].Ki;
#else
const float Ki = pidCoefficient[axis].Ki;
// if launch control is active override the iterm gains and apply iterm windup protection to all axes
if (launchControlActive) {
Ki = launchControlKi;
axisDynCi = dynCi;
} else
#endif
pidData[axis].I = constrainf(previousIterm + (Ki * dynCi + agGain) * itermErrorRate, -itermLimit, itermLimit);
{
Ki = pidCoefficient[axis].Ki;
axisDynCi = (axis == FD_YAW) ? dynCi : dT; // only apply windup protection to yaw
}
pidData[axis].I = constrainf(previousIterm + (Ki * axisDynCi + agGain) * itermErrorRate, -itermLimit, itermLimit);
// -----calculate pidSetpointDelta
float pidSetpointDelta = 0;