mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Crash recovery - Fixes #4379
This commit is contained in:
parent
3ff074dfbe
commit
70973bad04
1 changed files with 15 additions and 11 deletions
|
@ -515,20 +515,24 @@ void pidController(const pidProfile_t *pidProfile, const rollAndPitchTrims_t *an
|
|||
previousRateError[axis] = rD;
|
||||
|
||||
// if crash recovery is on and accelerometer enabled then check for a crash
|
||||
if (pidProfile->crash_recovery && ARMING_FLAG(ARMED)) {
|
||||
if (motorMixRange >= 1.0f && inCrashRecoveryMode == false
|
||||
&& ABS(delta) > crashDtermThreshold
|
||||
&& ABS(errorRate) > crashGyroThreshold
|
||||
&& ABS(getSetpointRate(axis)) < crashSetpointThreshold) {
|
||||
inCrashRecoveryMode = true;
|
||||
crashDetectedAtUs = currentTimeUs;
|
||||
}
|
||||
if (cmpTimeUs(currentTimeUs, crashDetectedAtUs) < crashTimeDelayUs && (ABS(errorRate) < crashGyroThreshold
|
||||
|| ABS(getSetpointRate(axis)) > crashSetpointThreshold)) {
|
||||
if (pidProfile->crash_recovery) {
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
if (motorMixRange >= 1.0f && inCrashRecoveryMode == false
|
||||
&& ABS(delta) > crashDtermThreshold
|
||||
&& ABS(errorRate) > crashGyroThreshold
|
||||
&& ABS(getSetpointRate(axis)) < crashSetpointThreshold) {
|
||||
inCrashRecoveryMode = true;
|
||||
crashDetectedAtUs = currentTimeUs;
|
||||
}
|
||||
if (cmpTimeUs(currentTimeUs, crashDetectedAtUs) < crashTimeDelayUs && (ABS(errorRate) < crashGyroThreshold
|
||||
|| ABS(getSetpointRate(axis)) > crashSetpointThreshold)) {
|
||||
inCrashRecoveryMode = false;
|
||||
}
|
||||
} else {
|
||||
inCrashRecoveryMode = false;
|
||||
BEEP_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
axisPID_D[axis] = Kd[axis] * delta * tpaFactor;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue