1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 03:50:02 +03:00

TPA optimisations (#12721)

* TPA optimisations

* improvement, thanks @ledvinap

* update following review comments, thanks karatebrot and ledvinap

* include rx.h in pid_init.c to get PWM_RANGE_MIN

* review suggestion
This commit is contained in:
ctzsnooze 2023-05-12 02:38:15 +10:00 committed by GitHub
parent c6b3a1e129
commit 10067ad6ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 15 deletions

View file

@ -277,20 +277,9 @@ void pidResetIterm(void)
void pidUpdateTpaFactor(float throttle)
{
pidProfile_t *currentPidProfile;
currentPidProfile = pidProfilesMutable(systemConfig()->pidProfileIndex);
const float tpaBreakpoint = (currentPidProfile->tpa_breakpoint - 1000) / 1000.0f;
float tpaRate = currentPidProfile->tpa_rate / 100.0f;
if (throttle > tpaBreakpoint) {
if (throttle < 1.0f) {
tpaRate *= (throttle - tpaBreakpoint) / (1.0f - tpaBreakpoint);
}
} else {
tpaRate = 0.0f;
}
pidRuntime.tpaFactor = 1.0f - tpaRate;
const float throttleTemp = fminf(throttle, 1.0f); // don't permit throttle > 1 ? is this needed ? can throttle be > 1 at this point ?
const float throttleDifference = fmaxf(throttleTemp - pidRuntime.tpaBreakpoint, 0.0f);
pidRuntime.tpaFactor = 1.0f - throttleDifference * pidRuntime.tpaMultiplier;
}
void pidUpdateAntiGravityThrottleFilter(float throttle)