mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 13:55:18 +03:00
More aggresive FF for averaging <3
This commit is contained in:
parent
be016dc794
commit
86c309454f
1 changed files with 18 additions and 12 deletions
|
@ -44,6 +44,7 @@ static float prevAcceleration[XYZ_AXIS_COUNT];
|
||||||
static float prevRawSetpoint[XYZ_AXIS_COUNT];
|
static float prevRawSetpoint[XYZ_AXIS_COUNT];
|
||||||
static float prevDeltaImpl[XYZ_AXIS_COUNT];
|
static float prevDeltaImpl[XYZ_AXIS_COUNT];
|
||||||
static bool bigStep[XYZ_AXIS_COUNT];
|
static bool bigStep[XYZ_AXIS_COUNT];
|
||||||
|
static uint8_t averagingCount;
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
static float ffMaxRateLimit[XYZ_AXIS_COUNT];
|
static float ffMaxRateLimit[XYZ_AXIS_COUNT];
|
||||||
|
@ -51,11 +52,11 @@ static float ffMaxRate[XYZ_AXIS_COUNT];
|
||||||
|
|
||||||
void interpolatedSpInit(const pidProfile_t *pidProfile) {
|
void interpolatedSpInit(const pidProfile_t *pidProfile) {
|
||||||
const float ffMaxRateScale = pidProfile->ff_max_rate_limit * 0.01f;
|
const float ffMaxRateScale = pidProfile->ff_max_rate_limit * 0.01f;
|
||||||
uint8_t j = pidProfile->ff_interpolate_sp;
|
averagingCount = pidProfile->ff_interpolate_sp;
|
||||||
for (int i = 0; i < XYZ_AXIS_COUNT; i++) {
|
for (int i = 0; i < XYZ_AXIS_COUNT; i++) {
|
||||||
ffMaxRate[i] = applyCurve(i, 1.0f);
|
ffMaxRate[i] = applyCurve(i, 1.0f);
|
||||||
ffMaxRateLimit[i] = ffMaxRate[i] * ffMaxRateScale;
|
ffMaxRateLimit[i] = ffMaxRate[i] * ffMaxRateScale;
|
||||||
laggedMovingAverageInit(&setpointDeltaAvg[i].filter, j, (float *)&setpointDeltaAvg[i].buf[0]);
|
laggedMovingAverageInit(&setpointDeltaAvg[i].filter, averagingCount, (float *)&setpointDeltaAvg[i].buf[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,22 +114,27 @@ FAST_CODE_NOINLINE float interpolatedSpApply(int axis, bool newRcFrame, ffInterp
|
||||||
} else if (holdCount[axis] == 2) {
|
} else if (holdCount[axis] == 2) {
|
||||||
// interpolation was not applied
|
// interpolation was not applied
|
||||||
} else if (holdCount[axis] == 3) {
|
} else if (holdCount[axis] == 3) {
|
||||||
// after persistent flat period or recent big step up, no boost
|
// after persistent flat period, no boost
|
||||||
// reduces jitter from boost when flying smoothly
|
// reduces jitter from boost when flying smooth lines
|
||||||
|
// but only when no ff_averaging is active, eg hard core race setups
|
||||||
// WARNING: this means no boost if ADC is active on FrSky radios
|
// WARNING: this means no boost if ADC is active on FrSky radios
|
||||||
setpointAccelerationModified = 0.0f;
|
if (averagingCount > 1) {
|
||||||
|
setpointAccelerationModified /= averagingCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
holdCount[axis] = 0;
|
holdCount[axis] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// smooth deadband type suppression of FF when sticks are centred.
|
// smooth deadband type suppression of FF jitter when sticks are at or returning to centre
|
||||||
const float rawSetpointCentred = fabsf(rawSetpoint) / 2.0f;
|
// only when ff_averaging is 3 or more, for HD or cinematic flying
|
||||||
if (rawSetpointCentred < 1.0f) {
|
if (averagingCount > 2) {
|
||||||
// force zero FF when sticks are centred for smoothness
|
const float rawSetpointCentred = fabsf(rawSetpoint) / averagingCount;
|
||||||
setpointSpeedModified *= rawSetpointCentred;
|
if (rawSetpointCentred < 1.0f) {
|
||||||
setpointAccelerationModified *= rawSetpointCentred;
|
setpointSpeedModified *= rawSetpointCentred;
|
||||||
holdCount[axis] = 4;
|
setpointAccelerationModified *= rawSetpointCentred;
|
||||||
|
holdCount[axis] = 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setpointDeltaImpl[axis] = setpointSpeedModified * pidGetDT();
|
setpointDeltaImpl[axis] = setpointSpeedModified * pidGetDT();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue