Commit Graph

213 Commits

Author SHA1 Message Date
Gustavo Jose de Sousa ee7c40be61 AP_InertialSensor: BMI160: add backend
The reason of defining BMI160_MAX_FIFO_SAMPLES as 8 can be found on the
following histogram of the number of samples in the FIFO on each read while
performing the accelerometer calibration process:

Samples Count   Freq Acc. Freq
------------------------------
      1  3842 0.1201  0.120111
      2 13172 0.4118  0.531904
      3  9065 0.2834  0.815300
      4  2710 0.0847  0.900022
      5  2231 0.0697  0.969769
      6   816 0.0255  0.995279
      7   137 0.0043  0.999562
      8    13 0.0004  0.999969
     13     1 0.0000  1.000000
2016-07-15 16:46:06 -03:00
Gustavo Jose de Sousa e85ac8b2c5 AP_InertialSensor: inform maximum gyro average difference
While at it, define GYRO_INIT_MAX_DIFF_DPS.
2016-06-27 17:22:43 -03:00
Gustavo Jose de Sousa e6f62080f5 AP_InertialSensor: fix best_diff on gyro initialization
Without this patch, if accel_diff.length() > 0.2f and j == 0, then
best_diff[k] would be zero forever since diff_norm[k] >= 0 for any j.
2016-06-27 17:20:51 -03:00
Grant Morphett 34fa2a39bd AP_InertialSensor: Changing the default gyro filter from 10 to 4
This change is only for Rovers.
2016-06-16 14:37:55 +09:00
Lucas De Marchi b067bce140 AP_InertialSensor: remove support for flymaple 2016-05-23 21:49:45 -03:00
Lucas De Marchi 7503c1b6d4 AP_InertialSensor: update doc about used ids 2016-05-23 21:49:45 -03:00
dgrat 41661f815f AP_Math: Replace the pythagorous* functions with a variadic template
The new function can deal with a variable number of function parameters.
Additionally, I renamed the functions to norm(), because this is the
standard name used in several other projects.
2016-05-10 11:41:26 -03:00
Andrew Tridgell be41d402b5 AP_InertialSensor: added set of delta angle time for replay 2016-04-26 15:50:46 +10:00
Andrew Tridgell 4401cbec72 AP_InertialSensor: cope with zero delta angle time from Replay 2016-04-26 15:37:11 +10:00
mirkix c3a6a56ebb AP_InertialSensor: Add second MPU9250 autodetection to BBBmini 2016-04-24 10:57:57 -03:00
ashwinvasudevan e33812e1cb AP_InertialSensor: added missing brackets 2016-03-23 17:46:41 +09:00
raspilot 1d1d224c18 AP_InertialSensor: Enable dual IMU for raspilot 2016-03-18 21:51:37 -03:00
AndersonRayner c9d5c548a6 Corrects a bracket error for the LSM9DS0 IMU
Switches the probe of the accel and gyro so they boot correctly (was
failing the WHOAMI with a switched result)
2016-02-25 20:08:01 -03:00
Jonathan Challinger c454631be8 AP_InertialSensor: work around gyro and accel errors on startup 2016-02-19 16:40:52 +09:00
Lucas De Marchi 02a7fa5c2b AP_InertialSensor: MPU9250: use AP_HAL::Device abstraction
This makes MPU9250 be almost the same as MPU6000 driver. Work has been
done here to make than similar so it's easier to spot the differences.
2016-02-16 19:49:09 -02:00
Lucas De Marchi d2b267d026 AP_InertialSensor: LSM9DS0: use AP_HAL::SPIDevice abstraction 2016-02-16 19:49:09 -02:00
Lucas De Marchi 58f4624f8c AP_InertialSensor: L3G4200D: use AP_HAL::I2CDevice abstraction 2016-02-16 19:49:09 -02:00
Lucas De Marchi af846636e4 AP_InertialSensor: MPU60x0: use AP_HAL::Device abstraction 2016-02-16 19:49:09 -02:00
Lucas De Marchi 9c6bd38e91 AP_InertialSensor: sanitize includes
Due to the way the headers are organized changing a single change in an
inertial sensor driver would trigger a rebuild for most of the files in
the project. Time could be saved by using ccache (since most of the
things didn't change) but we can do better, i.e. re-organize the headers
so we don't have to re-build everything.

With this patch only AP_InertialSensor/AP_InertialSensor.h is exposed to
most users. There are some corner cases to integrate with some example
code, but most of the places now depend only on this header and this
header doesn't depend on the specific backends.

Now changing a single header, e.g. AP_InertialSensor_L3G4200D.h triggers
a rebuild only of these files:

	$ waf copter
	'copter' finished successfully (0.000s)
	Waf: Entering directory `/home/lucas/p/dronecode/ardupilot/build/minlure'
	[ 80/370] Compiling libraries/AP_InertialSensor/AP_InertialSensor.cpp
	[ 84/370] Compiling libraries/AP_InertialSensor/AP_InertialSensor_L3G4200D.cpp
	[310/370] Linking build/minlure/ArduCopter/libArduCopter_libs.a
	[370/370] Linking build/minlure/bin/arducopter
	Waf: Leaving directory `/home/lucas/p/dronecode/ardupilot/build/minlure'
2016-02-01 14:18:51 -02:00
Jonathan Challinger 4c2e6af6ee AP_InertialSensor: statically register with AP_AccelCal 2016-01-23 10:35:34 +09:00
Randy Mackay 081beacb8d AP_InertialSensor: replace sqrt with safe_sqrt to resolve compiler warning
Also add suppressing comment for missing break at end of switch
2016-01-23 10:10:17 +09:00
Andrew Tridgell ee453783eb AP_InertialSensor: added get_delta_angle_dt() API 2016-01-19 09:50:21 +11:00
Andrew Tridgell b2745bb545 AP_InertialSensor: we only need peak hold for negative X for now 2016-01-02 09:58:32 +11:00
Tom Pittenger 3aaf2b1d2b AP_InertialSensor: add pos/neg peak detector
new functions that get a filtered min/max accel peaks on each axis with fixed 500ms timeout:
    Vector3f get_accel_peak_hold_pos()
    Vector3f get_accel_peak_hold_neg()

This allows slower mechanisms, such as is_flying, to detect accel spikes which would indicate ground or object impacts. Vibe is too filtered. Independent positive and negative peaks are available
2016-01-02 09:58:31 +11:00
Jonathan Challinger 0a3c2774e9 AP_InertialSensor: fixes in response to review 2015-12-29 22:55:04 -08:00
Jonathan Challinger 137ace473d AP_InertialSensor: add accel_cal_requires_reboot 2015-12-29 10:46:35 -08:00
Jonathan Challinger f6a41a8936 AP_InertialSensor: ensure that accel calibration object isn't allocated more than once 2015-12-29 10:46:35 -08:00
Jonathan Challinger 492223cb84 AP_InertialSensor: support AP_AccelCal 2015-12-29 10:46:34 -08:00
Andrew Tridgell 17fc58f3cd AP_InertialSensor: re-work for more flexible main loop rates 2015-12-27 14:57:12 +09:00
Andrew Tridgell 93ef881109 AP_InertialSensor: added get_loop_delta_t() API 2015-12-27 14:57:10 +09:00
Andrew Tridgell 6639c23685 AP_InertialSensor: added QURT driver 2015-12-27 16:21:26 +11:00
Andrew Tridgell 28230556bb AP_InertialSensor: added qflight driver 2015-12-27 16:12:27 +11:00
Don Gagne 47586dae07 AP_InertialSensor: fix invalid Range meta data 2015-12-27 16:10:44 +11:00
Aaron Wang Shi 3a31970056 AP_InertialSensor: add support to BH hat
- MPU6050 I2C for BH v0.1
    - MPU9250 SPI for BH v0.2
2015-12-21 15:54:30 +11:00
Lucas De Marchi 2591261af6 Global: rename min and max macros to uppercase
The problem with using min() and max() is that they conflict with some
C++ headers. Name the macros in uppercase instead. We may go case by
case later converting them to be typesafe.

Changes generated with:

	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)max(/\1MAX(/g'
	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)min(/\1MIN(/g'
2015-12-01 16:28:09 -02:00
Caio Marcelo de Oliveira Filho d7601095fa AP_InertialSensor: use millis/micros/panic functions 2015-11-20 12:31:41 +09:00
Andrew Tridgell 4a768d47f3 AP_InertialSensor: created a SITL specific backend 2015-11-16 17:57:35 +11:00
Andrew Tridgell 75ea8f3dc0 AP_InertialSensor: removed "have sample" logic from drivers
the frontend has all the information it needs, so we can simplify the
drivers some more
2015-11-16 17:57:35 +11:00
Andrew Tridgell 0e4bab74ba AP_InertialSensor: simplify sensor backends
use common code for filtering and update, allowing each sensor driver
to be simpler and more consistent
2015-11-16 17:57:35 +11:00
José Roberto de Souza d1ff4286c2 AP_InertialSensor: Make detect_backends() public
This method will be used to initialize and configure I2C backends that
have an auxiliary I2C bus that can be connected to the main I2C bus,
like MPU6000 and MPU9250.
2015-11-11 14:29:07 +11:00
José Roberto de Souza b3322ed1ae AP_InertialSensor: Add MPU9250 over I2C to detect_backends() 2015-11-11 14:29:07 +11:00
José Roberto de Souza 588df53429 AP_InertialSensor: Add support to get auxiliary bus of multiple instances of the same sensor 2015-11-11 14:29:06 +11:00
Lucas De Marchi 3142f21363 AP_InertialSensor: remove checks for HAL_BOARD_APM2 and HAL_BOARD_APM1 2015-11-04 12:14:12 +11:00
Lucas De Marchi 62ba8266ef AP_InertialSensor: fix wrong printf format for printf
"%S" is used for wide string, but we are passing a char*. Use lowercase
in this case to remove warnings like this:

libraries/AP_InertialSensor/AP_InertialSensor.cpp: In member function
'bool AP_InertialSensor::calibrate_accel(AP_InertialSensor_UserInteract*, float&, float&)':
libraries/AP_InertialSensor/AP_InertialSensor.cpp:620:61: warning:
format '%S' expects argument of type 'wchar_t*', but argument 3 has type 'const char*' [-Wformat=]
                 "Place vehicle %S and press any key.\n", msg);
                                                             ^
2015-10-30 14:35:40 +09: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 1b07dabeb7 Replace prog_char and prog_char_t with char
prog_char and prog_char_t are now the same as char on supported
platforms. So, just change all places that use them and prefer char
instead.

AVR-specific places were not changed.
2015-10-30 14:35:30 +09:00
Lucas De Marchi 132303db4b AP_InertialSensor: use printf() rather than _printf_P() 2015-10-30 14:35:27 +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 a964ac38ec Replace use of print_P() with print() 2015-10-30 14:35:21 +09:00