Browse Source

AP_NavEKF: Add public function for estimated magnetometer offsets

mission-4.1.18
Paul Riseborough 10 years ago committed by Andrew Tridgell
parent
commit
14795719f6
  1. 14
      libraries/AP_NavEKF/AP_NavEKF.cpp
  2. 4
      libraries/AP_NavEKF/AP_NavEKF.h

14
libraries/AP_NavEKF/AP_NavEKF.cpp

@ -3650,6 +3650,20 @@ void NavEKF::getMagXYZ(Vector3f &magXYZ) const
magXYZ = state.body_magfield*1000.0f; magXYZ = state.body_magfield*1000.0f;
} }
// return magnetometer offsets
// return true if offsets are valid
bool NavEKF::getMagOffsets(Vector3f &magOffsets) const
{
// compass offsets are valid if we have finalised magnetic field initialisation and magnetic field learning is not prohibited
if (secondMagYawInit && (_magCal != 2)) {
magOffsets = _ahrs->get_compass()->get_offsets() - state.body_magfield*1000.0f;
return true;
} else {
magOffsets = _ahrs->get_compass()->get_offsets();
return false;
}
}
// return the last calculated latitude, longitude and height // return the last calculated latitude, longitude and height
bool NavEKF::getLLH(struct Location &loc) const bool NavEKF::getLLH(struct Location &loc) const
{ {

4
libraries/AP_NavEKF/AP_NavEKF.h

@ -145,6 +145,10 @@ public:
// return body magnetic field estimates in measurement units / 1000 // return body magnetic field estimates in measurement units / 1000
void getMagXYZ(Vector3f &magXYZ) const; void getMagXYZ(Vector3f &magXYZ) const;
// Return estimated magnetometer offsets
// Return true if magnetometer offsets are valid
bool getMagOffsets(Vector3f &magOffsets) const;
// return the last calculated latitude, longitude and height // return the last calculated latitude, longitude and height
bool getLLH(struct Location &loc) const; bool getLLH(struct Location &loc) const;

Loading…
Cancel
Save