Commit Graph

89 Commits

Author SHA1 Message Date
Randy Mackay b48864e1ad Copter: allow CH6 tuning of compass declination 2013-04-15 21:50:44 +09:00
Randy Mackay b8d492b504 Compass: current based compensation added 2013-03-03 23:02:12 +09:00
Randy Mackay e113eb526b Compass: add get_motor_compensation
Remove redundant set_motor_compensation call
2013-03-02 17:53:03 +09:00
Randy Mackay bfb29ce22b Compass: remove virtual functions to save RAM 2013-03-02 00:07:32 +09:00
Randy Mackay d8515ff85e Compass: basic compensation for motor interference 2013-03-02 00:03:16 +09:00
Andrew Tridgell 60a4447a86 AP_Compass: added set_board_orientation() method 2013-01-13 17:32:48 +11:00
Andrew Tridgell 741174f5d5 AP_Compass: first cut at a PX4 compass driver 2013-01-04 16:21:24 +11:00
Pat Hickey 3f1d9d7f69 AP_Param: #include <AP_Param.h> fixups for libraries & sketches
* I mostly went through with grep and added an #include <AP_Param.h> below
  every #include <AP_Common.h>. Not all of these example sketches might
  strictly need AP_Param.
2012-12-20 14:51:19 +11:00
Andrew Tridgell 6922dcdea2 Compass: added compass.accumulate() API
this allows us to accumulate mag readings using spare CPU cycles
2012-09-08 10:05:54 +10:00
uncrustify 04e48ef878 uncrustify libraries/AP_Compass/Compass.h 2012-08-21 19:19:51 -07:00
rmackay9 71f12fbc9b AP_Compass: replace "long" with "int32_t" 2012-08-18 16:58:16 +09: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
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 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
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 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 6a42598ade use stdint types in the compass code 2012-02-14 08:35:03 +11:00
Andrew Tridgell 8c58d95187 modify the compass code for AP_Param 2012-02-13 16:22:51 +11: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 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
rmackay9@yahoo.com da7a13128a 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
deweibel@gmail.com b5f0635455 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 aa598b575a 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
jasonshort b6245b471a 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 a4e791dc92 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 cc06f07067 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
DrZiplok eb81becdb6 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 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
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 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 2ca8ac7259 added ground_course in proper 0-360 degrees * 100 for Ardupilot
git-svn-id: https://arducopter.googlecode.com/svn/trunk@348 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-08-30 00:09:47 +00:00
jasonshort cf7eefd94b new Compass Lib
git-svn-id: https://arducopter.googlecode.com/svn/trunk@347 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-08-29 23:03:49 +00:00