1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Fix division by zero in mixer crashflip

This commit is contained in:
Bruce Luckcuck 2020-03-26 19:45:07 -04:00
parent 5b374c6fe0
commit 3c1e8cb1c3

View file

@ -699,7 +699,7 @@ static void applyFlipOverAfterCrashModeToMotors(void)
signYaw = 0;
}
const float cosPhi = (stickDeflectionPitchAbs + stickDeflectionRollAbs) / (sqrtf(2.0f) * stickDeflectionLength);
const float cosPhi = (stickDeflectionLength > 0) ? (stickDeflectionPitchAbs + stickDeflectionRollAbs) / (sqrtf(2.0f) * stickDeflectionLength) : 0;
const float cosThreshold = sqrtf(3.0f)/2.0f; // cos(PI/6.0f)
if (cosPhi < cosThreshold) {