Commit Graph

62 Commits

Author SHA1 Message Date
Staroselskii Georgii 7f00dd413f AP_Compass: fixed HMC5883's initialisation code 2014-11-14 10:21:04 +11:00
Jonathan Challinger 9054dd3f9a AP_Compass: use apply_correction_function to eliminate duplication 2014-10-19 17:02:45 +11:00
Randy Mackay 86aac4f40c Compass_HMC5843: use instance specific orient and external 2014-10-01 13:02:03 +10:00
Andrew Tridgell 54562b0b9a AP_Compass: prevent bad initial values from affecting HMC5883 calibration
the first couple of values after we enter strap mode may be low, but
just above our 0.7 threshold. We now discard the first two values to
prevent these affecting the average.

Also added some commented out debug code and a comment on the scaling
of the calibration code
2014-01-22 17:15:34 +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
Randy Mackay 84fdff4cd6 Compass: slightly relax HMC5843 calibration limits
Some users have reported Z axis values as high as 1.33.  Their compasses
seem otherwise health so extending the limits slightly.
2013-11-27 15:36:34 +09:00
Andrew Tridgell 1ccd6bb7ef AP_Compass: don't wait more than 1ms for compass sample
this prevents 5ms delays in compass accumulate
2013-10-08 11:50:54 +11:00
Andrew Tridgell 83c942a512 AP_Compass: prevent NULL deref on enable mag while running 2013-10-08 11:50:53 +11:00
Andrew Tridgell da14ad2e2d AP_Compass: neaten up HMC5883 debug 2013-09-28 21:24:02 +10:00
Andrew Tridgell 6fc5b06043 AP_Compass: fixed some old Serial.print calls 2013-09-28 21:24:02 +10:00
Mike McCauley 4c65c42411 AP_Compass: fixed ARM 32 bit compatibility 2013-09-23 18:10:21 +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
Andrew Tridgell 97b7130bb9 libraries: update license header to GPLv3
we switched to GPLv3 a long time ago, but neglected to update the
per-file license headers
2013-08-30 13:01:39 +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
Christopher Hrabia 9760cdf2d7 Compass: corrected space 2013-03-18 14:27:49 +09:00
Randy Mackay b8d492b504 Compass: current based compensation added 2013-03-03 23:02:12 +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
James Bielman 4fa7bb1486 Add AVR compatibility header for missing math.h definitions.
- Define float versions of math functions to the double versions
  on AVR (eg. #define sinf sin).
- These macros appear to be missing in older versions of avr-libs.
- Include AP_Math.h rather than math.h to get these definitions.
2013-01-16 13:52:17 +11:00
James Bielman 5631f865b2 Update floating point calculations to use floats instead of doubles.
- Allows use of hardware floating point on the Cortex-M4.
- Added "f" suffix to floating point literals.
- Call floating point versions of stdlib math functions.
2013-01-16 13:52:01 +11:00
Andrew Tridgell 60a4447a86 AP_Compass: added set_board_orientation() method 2013-01-13 17:32:48 +11:00
Andrew Tridgell 8f424cdf21 AP_Compass: ensure we check we got the semaphore 2013-01-09 20:42:20 +11:00
James Bielman eca1417858 AP_HAL: Add semaphores to I2C driver.
- Guard I2C transactions with this semaphore in the MS5611 and
  HMC5843 drivers.
2013-01-04 15:43:43 -08:00
Andrew Tridgell b70f7f57ba AP_Compass: restore low speed change on register read failure 2012-12-20 14:51:37 +11:00
Pat Hickey 53432a1101 AP_Compass: ported to AP_HAL 2012-12-20 14:51:26 +11:00
Andrew Tridgell daa4712078 AP_Compass: force I2C speed low in a couple more situations 2012-11-12 11:26:20 +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 4f9c6bbb19 uncrustify libraries/AP_Compass/AP_Compass_HMC5843.cpp 2012-08-21 19:01:20 -07: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
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 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 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
Andrew Tridgell 60185509f4 AP_Compass: when I2c fails, don't retry for 1s 2012-01-04 16:35:47 +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
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 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