Commit Graph

457 Commits

Author SHA1 Message Date
Lucas De Marchi eb75d73952 AP_Compass: remove checks for HAL_BOARD_APM2 and HAL_BOARD_APM1 2015-11-04 12:14:11 +11:00
Lucas De Marchi 5244559010 Minimize AP_Progmem.h includes
Most of AP_Progmem is already gone so we can stop including it in most
of the places. The only places that need it are the ones using
pgm_read_*() APIs.

In some cases the header needed to be added in the .cpp since it was
removed from the .h to reduce scope. In those cases the headers were
also reordered.
2015-10-30 14:35:32 +09:00
Lucas De Marchi 20c6ffc5e3 Replace use of UARTDriver::printf_P() with UARTDriver::printf()
This also starts to show warnings on places that were already using
wrong printf format strings.
2015-10-30 14:35:25 +09:00
Lucas De Marchi 6f4904189b Replace use of println_P() with println() 2015-10-30 14:35:22 +09:00
Lucas De Marchi 831d8acca5 Remove use of PROGMEM
Now variables don't have to be declared with PROGMEM anymore, so remove
them. This was automated with:

    git grep -l -z PROGMEM | xargs -0 sed -i 's/ PROGMEM / /g'
    git grep -l -z PROGMEM | xargs -0 sed -i 's/PROGMEM//g'

The 2 commands were done so we don't leave behind spurious spaces.

AVR-specific places were not changed.
2015-10-30 14:35:16 +09:00
Lucas De Marchi 2c38e31c93 Remove use of PSTR
The PSTR is already define as a NOP for all supported platforms. It's
only needed for AVR so here we remove all the uses throughout the
codebase.

This was automated with a simple python script so it also converts
places which spans to multiple lines, removing the matching parentheses.

AVR-specific places were not changed.
2015-10-30 14:35:04 +09:00
Lucas De Marchi e6b942ffb0 AP_Compass: use HMC5843 behind MPU6000 for minlure 2015-10-22 12:04:52 +11:00
Gustavo Jose de Sousa 63b42e0632 AP_Compass: Calibrator: make calculations for theta only once
Additionally, format comment on sample acceptance formulas nicely.
2015-10-22 08:19:35 +11:00
Gustavo Jose de Sousa f8433f82e6 AP_Compass: simplify calibration transition to COMPASS_CAL_RUNNING_STEP_ONE 2015-10-22 08:19:35 +11:00
Andrew Tridgell 4a8a24a1a2 AP_Compass: don't update last_update_usec for raw fields
this fixes a problem where the EKF gets compass samples at 50Hz
instead of the expected 10Hz
2015-10-21 13:22:24 +11:00
Lucas De Marchi 1a4a26de2b AP_Compass: remove check for max compass instances
For all supported boards the maximum number of instances is 3. The
number of HIL_COMPASSES was already defined as 2 instead of 3, so this
is left as before.
2015-10-21 10:05:18 +11:00
Lucas De Marchi 4004d5bf34 AP_Compass: remove check for HAL_CPU_CLASS
We don't support HAL_CPU_CLASS <= HAL_CPU_CLASS_16 anymore. This makes
COMPASS_MAX_INSTANCES and COMPASS_MAX_BACKEND constant for all supported
boards.
2015-10-21 10:05:18 +11:00
Caio Marcelo de Oliveira Filho a3169d0a34 AP_Compass: remove unnecessary includes from example 2015-10-21 09:16:11 +11:00
Caio Marcelo de Oliveira Filho ec52df991c build: compile only the HAL files needed by the board
Instead of requiring every program to specify the HAL related modules,
let the build system do it (in practice everything we compiled depended
on HAL anyway). This allow including only the necessary files in the
compilation.
2015-10-21 09:16:07 +11:00
Caio Marcelo de Oliveira Filho 2e464a53c2 AP_HAL: make code not depend on concrete HAL implementations
The switching between different AP_HAL was happening by giving different
definitions of AP_HAL_BOARD_DRIVER, and the programs would use it to
instantiate.

A program or library code would have to explicitly include (and depend)
on the concrete implementation of the HAL, even when using it only via
interface.

The proposed change move this dependency to be link time. There is a
AP_HAL::get_HAL() function that is used by the client code. Each
implementation of HAL provides its own definition of this function,
returning the appropriate concrete instance.

Since this replaces the job of AP_HAL_BOARD_DRIVER, the definition was
removed.

The static variables for PX4 and VRBRAIN were named differently to avoid
shadowing the extern symbol 'hal'.
2015-10-21 09:16:07 +11:00
Jonathan Challinger 78af6d61de AP_Compass: only play compass cal cancel tone if a cal was running 2015-10-21 08:24:49 +11:00
Jonathan Challinger 562db11159 AP_Compass: fix potential AP_Notify concurrency problem 2015-10-20 20:54:02 +09:00
José Roberto de Souza 3888579c07 AP_Compass: HMC5843: Use the correctly spelled method 2015-10-16 10:16:24 +11:00
Randy Mackay 6bdeae97b6 Compass: update param descriptions
offset parameter units are milligauss
User settable parameters should have a User category defined.  Those that should never be set by a user should not have this.
2015-10-15 20:52:38 +09:00
Randy Mackay 131536a3a7 Compass: resolve compiler warning 2015-10-15 20:33:25 +09:00
Gustavo Jose de Sousa 0caaef7394 AP_Compass: mention mag field unit in existing documentation
We are now always using milligauss for mag field unit, so let's update
documentation accordingly.
2015-10-15 19:56:15 +09:00
Gustavo Jose de Sousa 9927cf066f AP_Compass: remove use of milligauss_ratio
Now, we have all current compasses publishing their values already in
milligauss, so there's no need for that variable anymore.
2015-10-15 19:56:14 +09:00
Gustavo Jose de Sousa b603641d7c AP_Compass: AK8963: fix where to apply sensitivity adjustments
The function rotate_field() can change the values axes and the function
correct_field() applies offsets (which are already in milligauss). Thus any
sensitivity adjustment must be done for two reasons:

    (1) The offsets must be applied to the values already in milligauss;
    (2) The factory sensitivity adjustment values are per axis, if any rotation
        that switches axes is applied, that'll mess with the adjustment.

Experiments showed that before this patch the length of the mag field reported
quite different from the expected. After this patch, the same experiments
showed reasonable values.
2015-10-15 19:56:13 +09:00
Gustavo Jose de Sousa 6198e81bb3 AP_Compass: AK8963: scale mag field internally
This is part of the transition to make all mag field values be used in
milligauss.
2015-10-15 19:56:12 +09:00
Gustavo Jose de Sousa 256c9c06c9 AP_Compass: HMC5843: scale mag field internally
This is part of the transition to make all mag field values be used in
milligauss. Additionally the value of _gain_multiple is adapted to the new way
we're using it and corrected accordingly to the datasheets.
2015-10-15 19:56:11 +09:00
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
Gustavo Jose de Sousa 88a1a928e9 AP_Compass: remove get_{field,offsets}_milligauss() functions
Those functions are not being used anymore.
2015-10-15 19:56:09 +09:00
Gustavo Jose de Sousa 99a55f9379 AP_Compass: use compass get_{field,offsets}() functions
Both functions are equivalent, so we're going to simply use
get_{field,offsets}() instead of get_{field,offsets}_milligauss().
2015-10-15 19:56:02 +09:00
Gustavo Jose de Sousa 4375606eeb AP_Compass: make get_field() and get_offsets() return milligauss
This is part of a transition to make AP_Compass always use a single unit for
magnetic field values, namely milligauss.
2015-10-15 19:55:59 +09:00
Randy Mackay 825abdbedc Compass: example sketch displays in milligauss 2015-10-07 21:35:24 +09:00
mirkix ddb8e67954 AP_Compass: Add support for more then one AK8963 2015-10-06 10:38:21 +11:00
José Roberto de Souza 1a2b5ff677 AP_Compass: AK8963: Remove unused AP_HAL::Semaphore attributes 2015-10-01 10:42:51 -03:00
José Roberto de Souza a9d34ac3bd AP_Compass: AK8963: Rename some SPI/I2C method parameters
On read/write operations the argument is the register that will be read or
write not the address, SPI don't even have the concept of device address.
2015-10-01 10:42:40 -03:00
mirkix eee9522ca5 AP_Compass: Add MPU9250 multiple instance support 2015-09-24 13:11:38 +10:00
raspilot 1b5e6849d9 AP_Compass: fix milligauss code in LSM303D driver 2015-09-16 16:52:17 +09:00
Randy Mackay fff5ec09eb AP_Compass: fix consistent check for less than three compasses
Also use vector functions where available
Use get_field_milligause instead of just get_field
2015-09-16 15:11:01 +09:00
Jonathan Challinger 87bbf1a487 AP_Compass: add consistent() function 2015-09-16 15:10:27 +09:00
Julien BERAUD 5602e4055b AP_Compass_AK8963: Fix Rotation on the Bebop 2015-09-15 14:45:17 +09:00
Andrew Tridgell fa9ff5b604 AP_Compass: added parameter for compass calibration fitness threshold 2015-09-14 17:01:14 +10:00
Lucas De Marchi 309e75f9ac AP_Compass: LSM303D: use c++11 initializer to avoid Wreorder 2015-09-14 14:22:15 +10:00
Lucas De Marchi 3a017c8702 AP_Compass: LSM303D: rename members to follow convention
Make the members have similar names as HMC5843 driver and prepend
underscore on private fields.
2015-09-14 14:22:15 +10:00
raspilot 19b4f5559a AP_Compass: added LSM303D driver 2015-09-14 14:22:15 +10: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
Andrew Tridgell 3699932417 AP_Compass: fixed SITL compass 2015-09-09 14:53:11 +10:00
Staroselskii Georgii bd7c313bee AP_Compass: fixed Compass::get_raw_field()
It seems as if it were a copy-paste error. A statis analyzer would
definetely be angry.
2015-09-09 10:38:17 +10:00
Staroselskii Georgii e93ff44a97 AP_Compass: make a transition to milligauss in Compass library 2015-09-09 10:38:16 +10:00
Staroselskii Georgii 693613aa0f AP_Compass: convert AK8963 measurements to uT
AK8963 is configured in 16-bit ADC mode which implies sensitivity of 0.15 uT/LSb. Knowing this fact we can convert the measurements to the proper units. The change will make users recalibrate their compasses.
2015-09-09 10:38:16 +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
Andrew Tridgell 6991a1b9e9 AP_Compass: ensure we have payload space to send MAG_CAL messages 2015-09-07 08:58:11 +10:00
Andrew Tridgell 2baa0ac2f2 AP_Compass: disable COMPASS_LEARN when mag calibration used 2015-09-07 08:07:17 +10:00
Andrew Tridgell 079161ef3a AP_Compass: fixed raw_field init in AK8963 driver
thanks to Peter for spotting this
2015-09-03 21:27:22 +10:00
Andrew Tridgell e4b2fc711d AP_Compass: added message for compass cal when armed 2015-09-03 16:59:22 +10:00
Andrew Tridgell f4cdf57d8f AP_Compass: added handling of compass calibration mavlink messages 2015-09-03 16:59:14 +10:00
Siddharth Bharat Purohit 75829f5533 AP_Compass: remove extra compass field correction 2015-09-03 16:59:14 +10:00
Siddharth Bharat Purohit 3abdf85796 AP_Compass_Calibrator: remove unrequired variables 2015-09-03 16:59:14 +10:00
Siddharth Bharat Purohit c126017035 AP_Compass: reduce to if healthy check from if-else 2015-09-03 16:59:14 +10:00
Siddharth Bharat Purohit 2fb002798c generate.sh 2015-09-03 16:59:14 +10:00
Siddharth Bharat Purohit 63973bff31 AP_Compass_AK8963: move variable declarations before goto 2015-09-03 16:59:14 +10:00
Siddharth Bharat Purohit 6a603eb594 Compass_cal: implement the concept of auto and mandatory user reboot after cal 2015-09-03 16:59:13 +10:00
Gustavo Jose de Sousa 46774136a6 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-09-03 16:59:13 +10:00
Siddharth Bharat Purohit cdd8bae6ac AP_Compass: publish raw and unfiltered field for HMC5843 compass 2015-09-03 16:59:13 +10:00
Siddharth Bharat Purohit 8cdc9748b3 AP_Compass: publish raw and unfiltered field for AK8963 compass 2015-09-03 16:59:13 +10:00
Siddharth Bharat Purohit f085e274c7 AP_Compass: add explaination for sample acceptance based on angular distance 2015-09-03 16:59:13 +10:00
Jonathan Challinger f108383c11 AP_Compass: initialize CompassCalibrator _sample_buffer to NULL 2015-09-03 16:59:13 +10:00
Jonathan Challinger 358736a592 AP_Compass: correct calibrator sample acceptance math 2015-09-03 16:59:13 +10:00
Jonathan Challinger bff9b9065e AP_Compass: CompassCalibrator comment update 2015-09-03 16:59:13 +10:00
Siddharth Bharat Purohit 137bd25220 AP_Compass: add info about compass calibrator procedure 2015-09-03 16:59:12 +10:00
Siddharth Bharat Purohit f5fbc2fac1 AP_Compass: use AP_Math inverse library 2015-09-03 16:59:12 +10:00
Jonathan Challinger 0edf1df28e AP_Compass: loosen calibration acceptance tolerance 2015-09-03 16:59:12 +10:00
Jonathan Challinger 987f55387e AP_Compass: style cleanup 2015-09-03 16:59:12 +10:00
Jonathan Challinger 5ef713f3db AP_Compass: set AP_Notify::compass_cal_failed 2015-09-03 16:59:12 +10:00
Jonathan Challinger 5a12991d29 CompassCalibrator: remove dependence on AP_Notify 2015-09-03 16:59:12 +10:00
Jonathan Challinger de600ca3da AP_Compass: configured() only checks compasses with _USE set 2015-09-03 16:59:12 +10:00
Jonathan Challinger 72c8d0f530 AP_Compass: add samples to calibrator when published 2015-09-03 16:59:11 +10:00
Jonathan Challinger cc36401b7c AP_Compass: add calibration interface 2015-09-03 16:59:11 +10:00
Jonathan Challinger 05d3616e0d AP_Compass: fix sitl build 2015-09-03 16:59:11 +10:00
Jonathan Challinger 7cb9fa8898 AP_Compass: Correct parameter checks in compass cal 2015-09-03 16:59:11 +10:00
Jonathan Challinger 6d45660568 AP_Compass: refactor run_fit_chunk logic 2015-09-03 16:59:11 +10:00
Jonathan Challinger f2acf2cb88 AP_Compass: more parameter checks in compass calibrator 2015-09-03 16:59:11 +10:00
Jonathan Challinger 929ddb5685 AP_Compass: fix a math error in the compass calibrator 2015-09-03 16:59:10 +10:00
Jonathan Challinger 328cf82c3d CompassCalibrator: update AP_Notify on failure 2015-09-03 16:59:10 +10:00
Jonathan Challinger bfdbb55528 AP_Compass: make compasscalibrator running() public 2015-09-03 16:59:10 +10:00
Jonathan Challinger d31d385490 AP_Compass: changes and fixes to LMA-based compass calibrate 2015-09-03 16:59:10 +10:00
bugobliterator c66bfc95e1 Compass: Add Levenberg-Marquadt for ellipsoid fit 2015-09-03 16:59:10 +10:00
bugobliterator 7711dde2ad Compass: implement 9 parameter ellipsoid fit 2015-09-03 16:59:10 +10:00
bugobliterator 35555c7b21 Compass: Add math for 9 parameter fitting 2015-09-03 16:59:10 +10:00
bugobliterator 7295537e8a Compass: decrease sphere coverage to 1/3rd
for faster sample collection
2015-09-03 16:59:10 +10:00
bugobliterator a2bd4e8997 Compass: Add less complex equations to calculate jacobians 2015-09-03 16:59:10 +10:00
bugobliterator 2ca0e80dc5 Compass: Add conditions to check sanity of results 2015-09-03 16:59:10 +10:00
bugobliterator 54bc28c96d Compass: Add Levenberg-Marquadt optimiser for sphere_fit
increase iterations to get good results from LM
better check for convergence, comparison with initial fitness is a better way to determine if convergence occurs, if fitness has not improved compared to initial fitness it means optimiser has failed.
2015-09-03 16:59:10 +10:00
Jonathan Challinger c0a662c819 AP_Compass: CompassCalibrator initial commit 2015-09-03 16:59:10 +10:00
Jonathan Challinger f20ef69777 Compass: add soft-iron corrections 2015-09-03 16:59:09 +10:00
Jonathan Challinger 5fe6db0dc9 AP_Compass_PX4: use new compass backend interface 2015-09-03 16:59:09 +10:00
Jonathan Challinger ade39abc7f AP_Compass_HMC5843: use new compass backend interface 2015-09-03 16:59:09 +10:00
Jonathan Challinger 8800d03fce AP_Compass_HIL: use new compass backend interface 2015-09-03 16:59:09 +10:00
Jonathan Challinger cd5cf45ba8 AP_Compass_AK8963: use new compass backend interface 2015-09-03 16:59:09 +10:00
Jonathan Challinger add1b8c257 AP_Compass: modify backend interface to push raw samples to frontend 2015-09-03 16:59:09 +10:00
Jonathan Challinger b990eaed68 AP_Compass: add interface for raw and unfiltered field 2015-09-03 16:59:09 +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