mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
Move to pid.c, add relax to offset drag based component, make configurable
This commit is contained in:
parent
4442de5591
commit
d4512672fe
3 changed files with 20 additions and 1 deletions
|
@ -178,6 +178,8 @@ void resetPidProfile(pidProfile_t *pidProfile)
|
|||
.launchControlAngleLimit = 0,
|
||||
.launchControlGain = 40,
|
||||
.launchControlAllowTriggerReset = true,
|
||||
.use_integrated_yaw = false,
|
||||
.integrated_yaw_relax = 200
|
||||
);
|
||||
#ifdef USE_DYN_LPF
|
||||
pidProfile->dterm_lowpass_hz = 150;
|
||||
|
@ -436,6 +438,8 @@ static FAST_RAM_ZERO_INIT uint8_t launchControlMode;
|
|||
static FAST_RAM_ZERO_INIT uint8_t launchControlAngleLimit;
|
||||
static FAST_RAM_ZERO_INIT float launchControlKi;
|
||||
#endif
|
||||
static FAST_RAM_ZERO_INIT bool useIntegratedYaw;
|
||||
static FAST_RAM_ZERO_INIT uint8_t integratedYawRelax;
|
||||
|
||||
void pidResetIterm(void)
|
||||
{
|
||||
|
@ -573,6 +577,8 @@ void pidInitConfig(const pidProfile_t *pidProfile)
|
|||
}
|
||||
launchControlKi = ITERM_SCALE * pidProfile->launchControlGain;
|
||||
#endif
|
||||
useIntegratedYaw = pidProfile->use_integrated_yaw;
|
||||
integratedYawRelax = pidProfile->integrated_yaw_relax;
|
||||
}
|
||||
|
||||
void pidInit(const pidProfile_t *pidProfile)
|
||||
|
@ -1241,7 +1247,13 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT
|
|||
}
|
||||
#endif
|
||||
// calculating the PID sum
|
||||
pidData[axis].Sum = pidData[axis].P + pidData[axis].I + pidData[axis].D + pidData[axis].F;
|
||||
const float pidSum = pidData[axis].P + pidData[axis].I + pidData[axis].D + pidData[axis].F;
|
||||
if (axis == FD_YAW && useIntegratedYaw) {
|
||||
pidData[axis].Sum += pidSum * dT * 100.0f;
|
||||
pidData[axis].Sum -= pidData[axis].Sum * integratedYawRelax / 100000.0f * dT / 0.000125f;
|
||||
} else {
|
||||
pidData[axis].Sum = pidSum;
|
||||
}
|
||||
}
|
||||
|
||||
// Disable PID control if at zero throttle or if gyro overflow detected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue