ardupilot/libraries/AP_Compass
Doug Weibel 622217357c Bug fix for compass.
This is a fix for an interesting bug when a DCM matrix reset was added to the ground start.  This bug only showed up if (A) a ground start were performed after an air start or due to use of the "Calibrate Gryo" action, (B) if the current orientation were sufficiently different from 0/0/0, and (C.) if the particular magnetometer had sufficiently large offsets.  Why did resetting the DCM matrix to 0/0/0 pitch/roll/yaw at ground start cause a bug?  The magnetometer offset nulling determines the proper offsets for the magnetometer by comparing the observed change in the magnetic field vector with the expected change due to rotation as calculated from the rotation in the DCM matrix.  This comparison is made at 10Hz, and then filtered with a weight based on the amount of rotation to estimate the offsets. Normally it would take considerable time at normal in-flight rotation rates for the offset estimate to converge. 

If a DCM matrix reset occurs when the offset nulling algorithm is up and running, the algorithm sees the DCM reset as a instantaneous rotation, however the magnetic field vector did not change at all.  Under certain conditions the algorithm would interpret this as indicating that the offset(s) should be very large.  Since the "rotation" could also have been large the filter weighting would be large and it was possible for a large erroneous estimate of the offset(s) to be made based on this single (bad) data point.

To fix this bug methods were added to the compass object to start and stop the offset nulling algorithm.  Further, when the algorithm is started, it is set up to get fresh samples.  The DCM matrix reset method now calls these new methods to stop the offset nulling before resetting the matrix, and resume after the matrix has been reset.
2012-01-12 14:44:24 -07:00
..
examples/AP_Compass_test compass: show timing in compass test 2011-12-28 21:44:18 +11:00
AP_Compass.h Compass: removed the old 5883L driver 2011-08-13 05:09:58 +00:00
AP_Compass_HIL.cpp I2C: convert compass code to new I2C library 2011-12-28 20:41:53 +11:00
AP_Compass_HIL.h I2C: convert compass code to new I2C library 2011-12-28 20:41:53 +11:00
AP_Compass_HMC5843.cpp AP_Compass: when I2c fails, don't retry for 1s 2012-01-04 16:35:47 +11:00
AP_Compass_HMC5843.h AP_Compass: when I2c fails, don't retry for 1s 2012-01-04 16:35:47 +11:00
Compass.cpp Bug fix for compass. 2012-01-12 14:44:24 -07:00
Compass.h Bug fix for compass. 2012-01-12 14:44:24 -07:00
keywords.txt AP_Compass - changed include for AP_Math to use relative path (it was erroring for me at least when compiling ArduCopterNG with AP_Compass) 2010-12-12 14:02:21 +00:00