1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 01:05:27 +03:00

Merge pull request #9647 from etracer65/mixer_crashflip_div0

Fix division by zero in mixer crashflip
This commit is contained in:
Michael Keller 2020-03-28 14:02:13 +13:00 committed by GitHub
commit 5f8fc1e6f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -699,7 +699,7 @@ static void applyFlipOverAfterCrashModeToMotors(void)
signYaw = 0; 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) const float cosThreshold = sqrtf(3.0f)/2.0f; // cos(PI/6.0f)
if (cosPhi < cosThreshold) { if (cosPhi < cosThreshold) {