mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Rate limiter
This commit is contained in:
parent
09f5c85817
commit
6c8a8614fc
1 changed files with 2 additions and 2 deletions
|
@ -80,14 +80,14 @@ float calculateRate(int axis, const controlRateConfig_t *controlRateConfig) {
|
||||||
|
|
||||||
if (isSuperExpoActive()) {
|
if (isSuperExpoActive()) {
|
||||||
float rcFactor = (axis == YAW) ? (ABS(rcCommand[axis]) / 500.0f) : (ABS(rcCommand[axis]) / (500.0f * (controlRateConfig->rcRate8 / 100.0f)));
|
float rcFactor = (axis == YAW) ? (ABS(rcCommand[axis]) / 500.0f) : (ABS(rcCommand[axis]) / (500.0f * (controlRateConfig->rcRate8 / 100.0f)));
|
||||||
rcFactor = 1.0f / (1.0f - (rcFactor * (controlRateConfig->rates[axis] / 100.0f)));
|
rcFactor = constrainf(1.0f / (1.0f - (rcFactor * (controlRateConfig->rates[axis] / 100.0f))), 0.01f, 1.00f);
|
||||||
|
|
||||||
angleRate = rcFactor * ((27 * rcCommand[axis]) / 16.0f);
|
angleRate = rcFactor * ((27 * rcCommand[axis]) / 16.0f);
|
||||||
} else {
|
} else {
|
||||||
angleRate = (float)((controlRateConfig->rates[axis] + 27) * rcCommand[axis]) / 16.0f;
|
angleRate = (float)((controlRateConfig->rates[axis] + 27) * rcCommand[axis]) / 16.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return angleRate;
|
return constrainf(angleRate, -8190, 8290); // Rate limit protection
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t getDynamicKp(int axis, const pidProfile_t *pidProfile) {
|
uint16_t getDynamicKp(int axis, const pidProfile_t *pidProfile) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue