Commit Graph

55 Commits

Author SHA1 Message Date
Andrew Tridgell c44d8b45ce AP_Compass: auto-select healthy compass 2013-12-09 20:01:42 +11:00
Andrew Tridgell 61f564d7c9 AP_Compass: support motor compensation for multiple compasses
Pair-Programmed-With: Randy Mackay <rmackay9@yahoo.com>
2013-12-09 19:45:31 +11:00
Andrew Tridgell c538816825 AP_Compass: support compass health status on multiple compasses 2013-12-09 17:46:41 +11:00
Andrew Tridgell bde89fd4e2 AP_Compass: added compass offsets for 2nd compass 2013-12-09 17:34:07 +11:00
Andrew Tridgell 8a97042fb1 AP_Compass: updates to support multiple compasses 2013-12-09 17:34:07 +11:00
Andrew Tridgell cb16733918 AP_Compass: switched to a vector based interface
this is more consistent with other APIs and makes multi-device support
easier
2013-12-09 17:34:06 +11:00
Andrew Tridgell f286369990 AP_Compass: fixed orientation on Linux 2013-10-08 11:50:54 +11:00
Andrew Tridgell 1243ab9e63 AP_Compass: added HAL_Linux support 2013-09-28 21:24:02 +10:00
Andrew Tridgell 3f0f8dfa62 AP_Compass: removed SMACCM support 2013-09-26 22:38:31 +10:00
Mike McCauley 2fa0c39f3a AP_Compass: added Flymaple orientation 2013-09-24 13:18:35 +10:00
Andrew Tridgell fbf79c07f0 AP_Compass: added COMPASS_EXTERNAL option
this allows configuring of a compass as being externally attached
2013-08-30 14:02:09 +10:00
Tobias ab311d1dd4 AP_Compass: removed comparison out of range compiler warning
uint_ >= 0 (-Wtype-limits)
2013-07-08 14:57:25 +10:00
Andrew Tridgell 9a87b3f3c1 AP_Compass: use const on more functions and remove old calculate_heading()
the calculate_heading() based on roll/pitch is not needed anywhere
2013-05-09 09:24:06 +10:00
Andrew Tridgell 217f34e155 AP_Compass: added COMPASS_ORIENT parameter, to support external compasses
this allows the user to configure the compass for any orientation
supported by our rotation library
2013-05-02 12:48:14 +10:00
Andrew Tridgell 26fa5c40f1 Compass: use const references for some functions 2013-04-22 13:26:49 +10:00
Randy Mackay b8974dec99 Copter: compass learn off by default 2013-04-16 18:47:39 +09:00
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