Commit Graph

52 Commits

Author SHA1 Message Date
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
Andrew Tridgell 7aa294eca2 AP_Compass: when I2c fails, don't retry for 1s 2012-01-04 16:35:47 +11:00
Andrew Tridgell 5f0e070f4e compass: show timing in compass test 2011-12-28 21:44:18 +11:00
Andrew Tridgell f93c716126 I2C: convert compass code to new I2C library
this also adds a healthy attribute, and error checking on all I2C
calls
2011-12-28 20:41:53 +11:00
Andrew Tridgell 67e5c89226 compass: added AP_COMPASS_APM2_SHIELD
this makes the orientation clearer
2011-11-25 20:00:18 -08:00
James Goppert ac3e73f5c0 Optional recursion added. 2011-09-30 17:17:51 -04:00
James Goppert 112d5e9531 Improvements to cmake. 2011-09-29 21:23:26 -04:00
James Goppert 3a00ceb593 Added ArduBoat/ ArduRover/ and APO library. 2011-09-29 14:12:15 -04:00
unknown 9f028bb5a0 Adding CMake support 2011-09-14 15:44:55 +02:00
tridge60@gmail.com eb8de79be4 Compass: added a gain multiplier
this adjusts the calibration based on the change in gain between
calibration and runtime

git-svn-id: https://arducopter.googlecode.com/svn/trunk@3090 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-08-13 10:39:11 +00:00
tridge60@gmail.com 32c576f28c Compass: several fixes to compass calibration code
this changes the calibration code to require at least 5 good reads
from the compass during initialisation. The calibration is taken as
the average of the 5 values.

This also fixes the expected values for the 3 axes for the 5883 to
match reality.

We also save a bit of code space by adding a common rotate_for_5883L()
routine.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@3087 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-08-13 08:17:25 +00:00
tridge60@gmail.com 1989497ae9 we don't have a separate 5883L driver any more
git-svn-id: https://arducopter.googlecode.com/svn/trunk@3085 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-08-13 06:30:13 +00:00
tridge60@gmail.com 9232a0f652 Compass: removed the old 5883L driver
we now use a single driver for both mags

git-svn-id: https://arducopter.googlecode.com/svn/trunk@3083 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-08-13 05:09:58 +00:00
tridge60@gmail.com 4f099ae158 cope with double initialisation of the compass
if we've already initialised, then the orientation matrix will already
be right

git-svn-id: https://arducopter.googlecode.com/svn/trunk@3072 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-08-10 14:07:15 +00:00
tridge60@gmail.com 2995878e99 compass: add a small delay in compass init
this adds a 50ms delay after setting the compass gains before reading
the compass. Added as paranoia after some strange results on a 5843

git-svn-id: https://arducopter.googlecode.com/svn/trunk@3070 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-08-10 12:47:25 +00:00
tridge60@gmail.com c22ebd22b4 compass: fixed a compiler warning
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2844 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-13 09:10:24 +00:00
tridge60@gmail.com db2e139812 fixed 5843 detection code
we were looking for the wrong regA value

Thanks to Chris for the debugging help! (and happy birthday!)

git-svn-id: https://arducopter.googlecode.com/svn/trunk@2828 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-09 22:27:15 +00:00
tridge60@gmail.com ddb823829d compass: added error checking on I2C transactions
this adds error checking to all operations on the compass, to ensure
that we don't accept invalid data

This also fixes the calibration values for the 5883L to match the
recommended values in the spec

git-svn-id: https://arducopter.googlecode.com/svn/trunk@2815 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-09 12:10:00 +00:00
jasonshort 8a0843e69a Added a limit to the atan function to calc the heading. Just trying to avoid, bad values screwing up the DCM. - Jason
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2777 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-08 03:56:04 +00:00
tridge60@gmail.com 02351bd23a compass: fixed normal operation mode change for 5883L
We need to set the right rates after config too. Thanks to Randy for
spotting this one

git-svn-id: https://arducopter.googlecode.com/svn/trunk@2737 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-03 12:00:45 +00:00
tridge60@gmail.com cde84445b3 compass: fixed output rate and averaging for 5883L
we need to setup the right output rate, or the compass gets very laggy

git-svn-id: https://arducopter.googlecode.com/svn/trunk@2736 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-03 08:32:58 +00:00
tridge60@gmail.com 8fcceaa919 AP_Compass: fixed calibration of 5883L compass
this fixes a compass initialisation bug where if the first value from
the compass isn't in the right range we would set bad calibration
scaling factors.

This also changes the maximum acceptable calibration values to 2000,
which is needed for the 5883 compass

pair-programmed-with: Randy Mackay

git-svn-id: https://arducopter.googlecode.com/svn/trunk@2718 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-02 11:31:38 +00:00
tridge60@gmail.com e9bb030fd4 AP_Compass: report compass initialisation failure
don't just put out rubbish values

git-svn-id: https://arducopter.googlecode.com/svn/trunk@2717 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-02 11:31:27 +00:00
rmackay9@yahoo.com fd2547216d AP_Compass_test - added display to auto detected compass
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2716 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-01 16:26:27 +00:00
rmackay9@yahoo.com f7ba02f825 AP_Compass - added auto detect of 5843 vs 5883L to AP_Compass_HMC5843 class
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2700 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-06-28 16:47:53 +00:00
rmackay9@yahoo.com 151aa5d415 AP_Compass - added auto detect of 5843 vs 5883L to AP_Compass_HMC5843 class
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2699 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-06-28 16:30:42 +00:00
rmackay9@yahoo.com b640e7b68c AP_Compass - added support for HMC5883L
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2461 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-06-01 13:21:20 +00:00
rmackay9@yahoo.com 9b1be05369 AP_Compass - added support for HMC5883L
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2460 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-06-01 13:16:18 +00:00
deweibel@gmail.com a19b5a5c10 Add an alternate compass.calculate() function substituting 1 sqrt func for 4 trig funcs.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2221 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-05-08 18:15:29 +00:00
james.goppert e6c4595d3c Massive warning fixes.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2089 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-05-04 19:12:27 +00:00
james.goppert a840314b97 APO merge.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1935 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-05-01 02:05:17 +00:00
james.goppert@gmail.com 2068c83cba Fixed bug in compass tests, had it initialize fastserial.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1862 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-04-09 19:57:54 +00:00
jasonshort 0ff00e3a53 added names to output in show
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1698 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-02-20 03:46:18 +00:00
mich146@hotmail.com b268578975 fix compass shim
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1684 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-02-19 10:04:00 +00:00
jasonshort 385e3af27e Added accessors declination.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1677 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-02-19 03:57:53 +00:00
DrZiplok@gmail.com b9152dc544 Line ending property changes.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1649 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-02-14 04:27:07 +00:00
DrZiplok@gmail.com 1f04ecbfdb Major update including AP_Var support.
Most of the compass functionality is now abstracted in a base class, with the various sub-classes implementing just their unique functionality.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1647 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-02-14 04:25:20 +00:00
deweibel fac0e0a1d9 Add code for auto magnetometer offset nulling.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1615 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-02-08 20:17:16 +00:00
DrZiplok 973879501b use memset rather than explicit assignments to zero to zero an array, this saves code space.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1340 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-28 23:32:37 +00:00
DrZiplok da957cf50d Pure virtual classes should declare pure virtual member functions as 0, rather than having the linker go looking for implementations elesewhere. This lets the compiler generate better error messages when a subclass fails to implement one or more required functions.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1339 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-28 23:31:58 +00:00
rmackay9@yahoo.com d5cc9946c5 AP_Compass - small change to include file used in example.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1152 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-18 04:48:52 +00:00
rmackay9@yahoo.com abacc627d8 AP_Compass - changed include for AP_Math to use relative path (it was erroring for me at least when compiling ArduCopterNG with AP_Compass)
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1113 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-12 14:02:21 +00:00
rmackay9@yahoo.com af741882c6 AP_Compass - moved example sketch from APM_Compass to AP_Compass
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1112 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-12 13:13:12 +00:00
jasonshort 963ee5843e git-svn-id: https://arducopter.googlecode.com/svn/trunk@1004 f9c3cf11-9bcb-44bc-f272-b75c42450872 2010-12-02 06:41:32 +00:00
james.goppert b66b0f6cce Fixed issues with AP_Compass
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1003 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-02 06:23:56 +00:00
jasonshort 729cf47b3c needs some help
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1001 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-02 05:54:02 +00:00
james.goppert 559229a667 Added HIL and HMC5843 compass libs.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@998 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-02 05:19:38 +00:00
james.goppert 45ddbbf982 Updated compass library.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@995 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-02 05:13:12 +00:00
deweibel 52ed7fac8c corrections to imu and dcm libs, addition of vector member to compass class for magnetic vector
git-svn-id: https://arducopter.googlecode.com/svn/trunk@844 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-11-15 02:15:16 +00:00
jasonshort 11ccbb9ed7 added ground_course 0-36000 for Ardupilot
git-svn-id: https://arducopter.googlecode.com/svn/trunk@353 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-08-30 00:18:56 +00:00