1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 19:40:31 +03:00

Fixed - reset all PID controller terms when PASSTHRU_MODE is active (#14058)

* [wing] reset all PID controller terms when PASSTHRU_MODE is active

* Update src/main/flight/pid.c

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* Update src/main/flight/pid.c

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

* Update src/main/flight/pid.c

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

---------

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
This commit is contained in:
Viacheslav Zhivetyev 2025-01-04 18:22:36 +01:00 committed by GitHub
parent f6985a8bfa
commit 60d35fa886
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1475,9 +1475,19 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, timeUs_t currentTim
} }
} }
#ifdef USE_WING
// When PASSTHRU_MODE is active - reset all PIDs to zero so the aircraft won't snap out of control
// because of accumulated PIDs once PASSTHRU_MODE gets disabled.
bool isFixedWingAndPassthru = isFixedWing() && FLIGHT_MODE(PASSTHRU_MODE);
#endif // USE_WING
// Disable PID control if at zero throttle or if gyro overflow detected // Disable PID control if at zero throttle or if gyro overflow detected
// This may look very innefficient, but it is done on purpose to always show real CPU usage as in flight // This may look very innefficient, but it is done on purpose to always show real CPU usage as in flight
if (!pidRuntime.pidStabilisationEnabled || gyroOverflowDetected()) { if (!pidRuntime.pidStabilisationEnabled
|| gyroOverflowDetected()
#ifdef USE_WING
|| isFixedWingAndPassthru
#endif
) {
for (int axis = FD_ROLL; axis <= FD_YAW; ++axis) { for (int axis = FD_ROLL; axis <= FD_YAW; ++axis) {
pidData[axis].P = 0; pidData[axis].P = 0;
pidData[axis].I = 0; pidData[axis].I = 0;