mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-09 01:13:57 -04:00
AP_NavEKF : Fixes bug in initial earth magnetic field states
The calculation for these states was not being bias corrected
This commit is contained in:
parent
7bff8e9312
commit
9c5f564dc5
@ -3010,7 +3010,7 @@ Quaternion NavEKF::calcQuatAndFieldStates(float roll, float pitch)
|
|||||||
readMagData();
|
readMagData();
|
||||||
|
|
||||||
// rotate the magnetic field into NED axes
|
// rotate the magnetic field into NED axes
|
||||||
initMagNED = Tbn*magData;
|
initMagNED = Tbn*(magData - magBias);
|
||||||
|
|
||||||
// calculate heading of mag field rel to body heading
|
// calculate heading of mag field rel to body heading
|
||||||
float magHeading = atan2f(initMagNED.y, initMagNED.x);
|
float magHeading = atan2f(initMagNED.y, initMagNED.x);
|
||||||
@ -3028,7 +3028,7 @@ Quaternion NavEKF::calcQuatAndFieldStates(float roll, float pitch)
|
|||||||
// calculate initial Tbn matrix and rotate Mag measurements into NED
|
// calculate initial Tbn matrix and rotate Mag measurements into NED
|
||||||
// to set initial NED magnetic field states
|
// to set initial NED magnetic field states
|
||||||
initQuat.rotation_matrix(Tbn);
|
initQuat.rotation_matrix(Tbn);
|
||||||
initMagNED = Tbn * magData;
|
initMagNED = Tbn * (magData - magBias);
|
||||||
|
|
||||||
// write to earth magnetic field state vector
|
// write to earth magnetic field state vector
|
||||||
state.earth_magfield = initMagNED;
|
state.earth_magfield = initMagNED;
|
||||||
|
Loading…
Reference in New Issue
Block a user