Commit Graph

82 Commits

Author SHA1 Message Date
rmackay9 9b3ced93ee AP_Compass: fix for mismatching set_initial_location parameters (forgot to change long to int32_t in .cpp file) 2012-08-18 20:41:38 +09:00
rmackay9 71f12fbc9b AP_Compass: replace "long" with "int32_t" 2012-08-18 16:58:16 +09:00
Andrew Tridgell 518d6365ff AP_Param: update remaining libraries for new constructor syntax 2012-08-08 12:11:57 +10:00
Andrew Tridgell e4d28b12e5 Compass: remove the need to call calculate() on the compass object
the new AHRS code doesn't use calculate() and the compass.heading
attribute. Instead it works on the raw magnetometer vector. This
change removes the internal calculate state from the compass object
and instead adds calculate_heading() for use by older code that
doesn't go via AHRS.

This significantly reduces the calculation involved in compass updates

The null offsets enable/disable code is also removed, as it is not
needed now that compass offsets are not linked to the AHRS state.
2012-06-27 16:01:50 +10:00
rmackay9 ef43da9b92 AP_Compass - changed parameter initialisation order to remove compiler warning 2012-04-09 17:37:02 +09:00
Andrew Tridgell 504c53f746 Compass: added COMPASS_AUTODEC option
when this is 1 (which is the default), we will get the declination
automatically via the AP_Declination library

when it is 0 we will use the value configured by the user
2012-03-30 14:25:27 +11:00
Andrew Tridgell 16deefce31 Compass: fixed a comment 2012-03-29 12:39:53 +11:00
Andrew Tridgell 17290836ef Compass: added some more comments
explain the algorithm a bit more
2012-03-29 12:39:53 +11:00
Andrew Tridgell b2d6db9479 Compass: implement noise resistant varient of offset learning
This adds a large amount of noise robustness to the compass offset
learning algorithm, at a cost of 120 bytes of memory. The changes are
based on a long discussion with Bill Premerlani.
2012-03-28 20:55:27 +11:00
Andrew Tridgell a72d4b46b3 Compass: implement Bills new offset nulling algorithm
this seems to work much better than the old algorithm, converging
faster and more accurately. Even better, it has no linkage to DCM, so
no possibility of nasty feedback effects
2012-03-27 15:37:24 +11:00
Andrew Tridgell 7daaadf776 Compass: fixed the order of rotations in the compass driver
this should fix the massive heading issues that people have been
reporting. Please test!
2012-03-12 17:33:15 +11:00
Adam M Rivera fe8c896d69 AP_Declination: Added method set_initial_location
This will set the declination based on lat/lon if the user has
not yet saved one to the EEPROM, OR if they have specified via the
config parameter that they want it to overwrite the declination every
3D fix.

Signed-off-by: Andrew Tridgell <tridge@samba.org>
2012-03-11 20:59:47 +11:00
Andrew Tridgell d10c4b76ad Compass: removed an incorrect comment 2012-03-11 20:07:38 +11:00
Andrew Tridgell 0da64e98f8 Compass: don't save the orientation to EEPROM
there is no point in saving this, the value is only configurable at
compile time for now, and is always set
2012-03-11 15:37:07 +11:00
Andrew Tridgell cb96dd975f Compass: update the compass driver to use the new vector.rotate() method 2012-03-11 15:37:07 +11:00
Andrew Tridgell 6eff9107ea Compass: change last_update to be in microseconds 2012-03-10 10:34:32 +11:00
Andrew Tridgell 6d356b6c6e Compass: fixed last_update time for HIL compass 2012-03-10 10:34:30 +11:00
rmackay9 fa34ac076e AP_Compass - fixed compile warning 2012-02-29 22:57:35 +09:00
rmackay9 c819a0f68a AP_Compass - fixed small compiler warning to do with order of parameters in constructor 2012-02-29 22:45:49 +09:00
Andrew Tridgell d0a6359b37 Compass: use constructor to set initial values for _learn and _use_for_yaw
this ensures they are set if you have MAG_ENABLE==0
2012-02-25 17:36:31 +11:00
Andrew Tridgell f59297d7a7 Compass: catch the case of a user enabling a compass mid-flight
if a compass has not been initialised at startup we can't enable it
mid-flight, as we don't have the orientation
2012-02-25 14:51:09 +11:00
Andrew Tridgell 664622523d Compass: added COMPASS_LEARN and COMPASS_USE parameters
these allow you to control if the compass should be used for yaw and
if it should learn its offsets. This is useful for locking in compass
offsets once they are confirmed to be good, and for learning offsets
without using them in flights.

The default is to behave the same as previously, which is
COMPASS_LEARN=1 and COMPASS_USE=1
2012-02-25 14:51:08 +11:00
Andrew Tridgell c354879f1f Compass: ensure we don't produce NAN values for compass heading
this leaves the previous heading values alone if we are at a pitch of
exactly 90 or -90, at which point we can't compute a meaningful
heading
2012-02-24 11:52:55 +11:00
Andrew Tridgell 62326c0f72 Compass: enable compass offsets for HIL compass
this makes the null_offsets algorithm have an effect for the HIL
compass that is used for SITL, which makes for easier testing of
compass calibration
2012-02-15 22:33:50 +11:00
Andrew Tridgell 6a42598ade use stdint types in the compass code 2012-02-14 08:35:03 +11:00
Andrew Tridgell 9c5a5473ab added indexes to group info structures 2012-02-13 16:22:52 +11:00
Andrew Tridgell bf4a77da81 convert libraries to new typesafe macros 2012-02-13 16:22:51 +11:00
Andrew Tridgell 8c58d95187 modify the compass code for AP_Param 2012-02-13 16:22:51 +11:00
Randy Mackay ed19c25a97 Arduino 1.0 - changed all #includes of "WProgram.h", "wiring.h" and "WConstants.h to "Arduino.h".
Modified FastSerial's write function to return size_t (number of bytes written).
2012-01-28 12:25:47 +09:00
Doug Weibel e22a83eec0 Add a CLI setup action to reset the magnetometer offsets
Since the magnetometer offsets are not available through the MAVLink parameter interface (since they are an AP_Var vector) this little feature allows them to be reset from the CLI.  Useful if you somehow get bad offsets or if you change magnetometer.  If you have a bad set of large offset values I have seen issues with the nulling algorithm have trouble converging to the proper values.  I have never seen it have trouble converging from 0/0/0, so this could be a useful feature from time to time.
2012-01-15 16:15:08 -07:00
Doug Weibel 9846822748 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 60185509f4 AP_Compass: when I2c fails, don't retry for 1s 2012-01-04 16:35:47 +11:00
Andrew Tridgell 820153d7ae compass: show timing in compass test 2011-12-28 21:44:18 +11:00
Andrew Tridgell acf4e9b61d 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 6093db948b compass: added AP_COMPASS_APM2_SHIELD
this makes the orientation clearer
2011-11-25 20:00:18 -08:00
James Goppert 0c7c508541 Optional recursion added. 2011-09-30 17:17:51 -04:00
James Goppert 5489b84f8e Improvements to cmake. 2011-09-29 21:23:26 -04:00
James Goppert d887a28b91 Added ArduBoat/ ArduRover/ and APO library. 2011-09-29 14:12:15 -04:00
unknown a4e001bbcf Adding CMake support 2011-09-14 15:44:55 +02:00
tridge60@gmail.com 0bf026e6ad 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 ab04055c35 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 5836e27813 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 c860fd736a 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 a604e30c7c 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 7d58916a9d 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 48f010f80c 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 165643c307 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 7b803a9e1a 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 0d31d9be10 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 90b0d769f8 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