mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 11:29:58 +03:00
Merge pull request #10778 from ctzsnooze/Allow-feedforward-in-Level-and-Horizon
This commit is contained in:
commit
86aa5cc84e
1 changed files with 4 additions and 2 deletions
|
@ -1100,9 +1100,11 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, timeUs_t currentTim
|
||||||
pidRuntime.oldSetpointCorrection[axis] = setpointCorrection;
|
pidRuntime.oldSetpointCorrection[axis] = setpointCorrection;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Only enable feedforward for rate mode and if launch control is inactive
|
// no feedforward in launch control
|
||||||
const float feedforwardGain = (flightModeFlags || launchControlActive) ? 0.0f : pidRuntime.pidCoefficient[axis].Kf;
|
float feedforwardGain = launchControlActive ? 0.0f : pidRuntime.pidCoefficient[axis].Kf;
|
||||||
if (feedforwardGain > 0) {
|
if (feedforwardGain > 0) {
|
||||||
|
// halve feedforward in Level mode since stick sensitivity is weaker by about half
|
||||||
|
feedforwardGain *= FLIGHT_MODE(ANGLE_MODE) ? 0.5f : 1.0f;
|
||||||
// no transition if feedforwardTransition == 0
|
// no transition if feedforwardTransition == 0
|
||||||
float transition = pidRuntime.feedforwardTransition > 0 ? MIN(1.f, getRcDeflectionAbs(axis) * pidRuntime.feedforwardTransition) : 1;
|
float transition = pidRuntime.feedforwardTransition > 0 ? MIN(1.f, getRcDeflectionAbs(axis) * pidRuntime.feedforwardTransition) : 1;
|
||||||
float feedForward = feedforwardGain * transition * pidSetpointDelta * pidRuntime.pidFrequency;
|
float feedForward = feedforwardGain * transition * pidSetpointDelta * pidRuntime.pidFrequency;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue