mirror of https://github.com/ArduPilot/ardupilot
AP_AHRS: avoid FPE when we don't have a compass reading
This commit is contained in:
parent
77a2b4acf6
commit
463270e0ee
|
@ -271,6 +271,10 @@ AP_AHRS_DCM::yaw_error_compass(void)
|
|||
// get the mag vector in the earth frame
|
||||
Vector2f rb = _dcm_matrix.mulXY(mag);
|
||||
|
||||
if (rb.length() < FLT_EPSILON) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
rb.normalize();
|
||||
if (rb.is_inf()) {
|
||||
// not a valid vector
|
||||
|
|
Loading…
Reference in New Issue