Commit Graph

35 Commits

Author SHA1 Message Date
Gustavo Jose de Sousa 814442563e AP_Compass: HMC5843: fix _calibrate()
The use of _gain_multiple is not necessary because the values of
expected_{x,yz} and _mag_{x,y,z} are both in sensor raw unit (i.e., lsbs).

That wasn't fixed before in order not to make APM users to recalibrate their
compasses.
2015-10-15 19:56:10 +09:00
Andrew Tridgell c59bdc12df AP_Compass: fix the milligauss handling
the previous approach assumed a 1:1 mapping between compass backends
and compass instances, which isn't true on PX4.

It also only setup milligauss offsets on a set_and_save call, which is
not the only way offsets change

this adds a milligauss_ratio per instance, which is considerably
simpler
2015-09-09 14:53:11 +10:00
Staroselskii Georgii c207d8c6a8 AP_Compass: add milligauss counterparts to get_field() and get_offsets()
From now on there's a pair get_field_milligauss() and
get_offsets_milligauss() that can make the transition to the common
units across all compasses easier.
2015-09-09 10:38:16 +10:00
Lucas De Marchi a66a201bf5 AP_Compass: HMC5843: Add support for MPU6000 auxiliary bus
Allow HMC5843 to be on MPU6000's auxiliary bus.
2015-08-28 12:39:09 +10:00
Lucas De Marchi 628e446e3e AP_Compass: HMC5843: use a struct for raw value
Like is done in AK8963, declare a raw_value struct.
2015-08-28 12:39:09 +10:00
Lucas De Marchi c66c9c41f2 AP_Compass: HMC5843: be agnostic to I2C bus
Like was done to inertial AK8963 and inertial sensor move the decision
regarding the I2C bus to the caller. We don't allow changing the address
because apparently HMC5843 doesn't support different addresses.

Changing only the bus could be more easily done but this prepares the
ground for using HMC5843 on an AuxiliarBus.

The need for a more generic abstraction is evidenced by this commit: a
"SerialBus" in AP_HAL would be a nice addition rather than letting each
driver to provide its own. However the methods are a little bit
different from what we have in AK8963. It's safer to do the simple
conversion now and later on to add the abstraction changing everybody to
use it.
2015-08-28 12:39:09 +10:00
Staroselskii Georgii 633330db14 AP_Compass: rename calibration array in HMC
I think naming the variable "scaling" makes more sense.
2015-08-28 12:39:09 +10:00
Staroselskii Georgii a9e8c1c464 AP_Compass: encapsulated calibration in HMC 2015-08-28 12:39:08 +10:00
Staroselskii Georgii 0fbc295d97 AP_Compass: encapsulated version detection in HMC driver 2015-08-28 12:39:08 +10:00
Lucas De Marchi 7e997564bf AP_Compass: standardize inclusion of libaries headers
Do the missing header changes due to changing the code before the pr
getting accepted.
2015-08-18 17:12:51 +10:00
Gustavo Jose de Sousa 58f300e78e AP_Compass: standardize inclusion of libaries headers
This commit changes the way libraries headers are included in source files:

 - If the header is in the same directory the source belongs to, so the
 notation '#include ""' is used with the path relative to the directory
 containing the source.

 - If the header is outside the directory containing the source, then we use
 the notation '#include <>' with the path relative to libraries folder.

Some of the advantages of such approach:

 - Only one search path for libraries headers.

 - OSs like Windows may have a better lookup time.
2015-08-11 16:28:42 +10:00
Andrew Tridgell d7bac39539 AP_Compass: removed two unused functions 2015-03-14 08:52:37 +11:00
Andrew Tridgell a871c87cad AP_Compass: use state array for compass variables 2015-03-13 18:46:15 +11:00
Víctor Mayoral Vilches d3b76cd8d3 AP_Compass: split compass into frontend/backend 2015-03-13 18:46:15 +11:00
Andrew Tridgell af50b652f8 AP_Compass: removed old orientation defines
we now use the rotations in libraries/AP_Math/rotations.h
2013-05-02 12:48:14 +10:00
Randy Mackay bfb29ce22b Compass: remove virtual functions to save RAM 2013-03-02 00:07:32 +09: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
Pat Hickey 53432a1101 AP_Compass: ported to AP_HAL 2012-12-20 14:51:26 +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 6bc9c5707f uncrustify libraries/AP_Compass/AP_Compass_HMC5843.h 2012-08-21 19:01:34 -07: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 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 8c58d95187 modify the compass code for AP_Param 2012-02-13 16:22:51 +11: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
Andrew Tridgell 6093db948b compass: added AP_COMPASS_APM2_SHIELD
this makes the orientation clearer
2011-11-25 20:00:18 -08: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 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
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
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
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
deweibel 8c76c8c936 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
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