AP_NavEKF3: Fix possible compass nullptr dereference

This commit is contained in:
Michael du Breuil 2017-07-31 12:22:51 -07:00 committed by Andrew Tridgell
parent b09b7f7867
commit e00811375b

View File

@ -404,6 +404,9 @@ void NavEKF3_core::getMagXYZ(Vector3f &magXYZ) const
// return true if offsets are valid
bool NavEKF3_core::getMagOffsets(uint8_t mag_idx, Vector3f &magOffsets) const
{
if (!_ahrs->get_compass()) {
return false;
}
// compass offsets are valid if we have finalised magnetic field initialisation, magnetic field learning is not prohibited,
// primary compass is valid and state variances have converged
const float maxMagVar = 5E-6f;