Plane: prevent a float exception at pitch 90

this can happen with a tailsitter
This commit is contained in:
Andrew Tridgell 2017-10-30 15:19:01 +11:00
parent 1ad929c56e
commit 9709bca7b4

View File

@ -156,9 +156,11 @@ void Plane::calc_gndspeed_undershoot()
Vector2f gndVel = ahrs.groundspeed_vector();
const Matrix3f &rotMat = ahrs.get_rotation_body_to_ned();
Vector2f yawVect = Vector2f(rotMat.a.x,rotMat.b.x);
yawVect.normalize();
float gndSpdFwd = yawVect * gndVel;
groundspeed_undershoot = (aparm.min_gndspeed_cm > 0) ? (aparm.min_gndspeed_cm - gndSpdFwd*100) : 0;
if (!yawVect.is_zero()) {
yawVect.normalize();
float gndSpdFwd = yawVect * gndVel;
groundspeed_undershoot = (aparm.min_gndspeed_cm > 0) ? (aparm.min_gndspeed_cm - gndSpdFwd*100) : 0;
}
}
}