Commit Graph

50 Commits

Author SHA1 Message Date
Gustavo Jose de Sousa 25a499a41f AP_InertialSensor: use raw sample rate terminology
In order to avoid confusion between sample rate from sensor and sample rate
from the frontend class (AP_InertialSensor), use "raw sample rate" to refer to
the former.

The changes in the code were basically done with the following commands:

git grep -wl _accel_sample_rates | xargs sed -i "s,\<_accel_sample_rates\>,_accel_raw_sample_rates,g"
git grep -wl _set_accel_sample_rate | xargs sed -i "s,\<_set_accel_sample_rate\>,_set_accel_raw_sample_rate,g"
git grep -wl _accel_sample_rate | xargs sed -i "s,\<_accel_sample_rate\>,_accel_raw_sample_rate,g"

git grep -wl _gyro_sample_rates | xargs sed -i "s,\<_gyro_sample_rates\>,_gyro_raw_sample_rates,g"
git grep -wl _set_gyro_sample_rate | xargs sed -i "s,\<_set_gyro_sample_rate\>,_set_gyro_raw_sample_rate,g"
git grep -wl _gyro_sample_rate | xargs sed -i "s,\<_gyro_sample_rate\>,_gyro_raw_sample_rate,g"

And also with minor changes on indentation and comments.
2015-10-22 16:53:11 +11:00
Gustavo Jose de Sousa dfd671c54e AP_InertialSensor: Backend: add hook for new gyro sample arrival
That hook will do common tasks for when new gyro raw sample is available.
2015-10-22 16:53:10 +11:00
mirkix 840f583d23 AP_InertialSensor: Add MPU9250 multiple instance support 2015-09-24 13:11:38 +10:00
Gustavo Jose de Sousa eb480e959c AP_InertialSensor: MPU9250: publish sample rate
That enables the default vibration calculation.
2015-09-07 11:14:42 +10:00
Gustavo Jose de Sousa a76eb9c15f AP_InertialSensor: MPU9250: use macros for sample rate
Instead of hardcoded values.
2015-09-07 11:14:42 +10:00
Gustavo Jose de Sousa e06627dfcb AP_InertialSensor: Backend: add hook for new raw accel samples
That hook will eventually do necessary things when a new accelerometer raw
sample arrives (like calculating vibration levels).
2015-09-07 11:14:42 +10:00
Gustavo Jose de Sousa ac3a677626 AP_InertialSensor: remove param rotate_and_correct from publish functions
Once that parameter is always false.
2015-09-07 11:14:42 +10:00
Gustavo Jose de Sousa fc38691e0b AP_InertialSensor: MPU9250: apply correction on each new sample
These changes are for enabling unified accelerometer vibration and clipping
calculation. For that, we need the values "rotated and corrected" before they
are filtered and the calculation must be called as soon as a new sample arrives
as it takes the sample rate into account.

Thus, move code that applies "corrections" to be executed as soon as accel data
arrive and call _publish_accel() passing rotate_and_correct parameter as false.
Also, do the same for gyro so we can keep it consistent.
2015-09-07 11:14:42 +10:00
Lucas De Marchi f18dd17377 AP_InertialSensor: fix typos
resister->register and fix copy and paste error from MPU6000 to MPU925.
2015-08-28 12:39:07 +10:00
Lucas De Marchi 2c44f3e313 AP_HAL_InertialSensor: 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:52 +10:00
Gustavo Jose de Sousa 7789aec85b AP_InertialSensor: 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:43 +10:00
Lucas De Marchi efec7723ff AP_InertialSensor: reset the MPU9250 chip on startup
Now that the initialization of MPU9250 is shared between the
AP_InertialSensor and other drivers using it as a backend, we can reset
the MPU9250 in order to put it in a known state.
2015-07-06 10:48:07 +10:00
Lucas De Marchi eb4e2ac2e5 AP_InertialSensor: factor out MPU9250 initialization
Now we have the initialization code split in 2 parts:

1) Making sure the MPU9250 chip is alive and working: this is now in a
static function that may be called by other drivers that use MPU9250 as
backend.

2) The configuration of gyro and accel. Once the first part is completed
successfully the AP_InertialSensor_MPU9250 finishes the configuration of
the sensors it uses.

The only change in behavior here is that before we would try 25 time (5x
inside _hardware_init time 5x inside _init_sensor() that calls the first
function) to "boot the chip" and now we are doing "only" 5.
2015-07-06 10:48:07 +10:00
Lucas De Marchi 953bfbd3fe AP_InertialSensor: provide static methods for spi transactions
Add static methods to do the SPI transactions and provide the wrapper
methods when we have an instance of the object. This is useful so these
methods can be called from other contexts when the AP_InertialSensor
hasn't been initialized yet.
2015-07-06 10:48:07 +10:00
mirkix f82344358f AP_InertialSensor: Change BBBMINI standard orientation 2015-07-06 10:12:39 +10:00
Staroselskii Georgii d40b45c9ae AP_InertialSensor: disable reset on MPU9250
The Compass library is initialized before the InertialSensor. AK8963 with
MPU9250 as backend already takes care of resetting MPU9250. The problem with
also resetting it in the MPU9250 initialization code is that if the reset
happens during an internal I2C transaction, the AK8963 may hang. So here we
remove the reset inside MPU9250. There still a possibility that the first
MPU9250 initialization is not successful and it resets the chip, but it's not
happening in tests.
2015-07-01 20:44:09 +03:00
Gustavo Jose de Sousa c72dc9bd45 AP_InertialSensor: make single rotation on MPU9250
The previous implementation made some boards apply two rotations to suit
their default orientation. That was happening because there was an
unconditional rotation being done (commented as "rotate for bbone
default").

This commit makes that unconditional rotation as a default rotation
instead and adjusts the former additional rotations to be single
rotations.
2015-06-22 17:45:20 +10:00
Gustavo Jose de Sousa 3dad768e8b AP_InertialSensor: log failure to initialize after max attempts on MPU9250
This happens for example when you are trying to use an SPI speed that's
above the one supported by the sensor or the controller.
2015-06-22 17:45:20 +10:00
Gustavo Jose de Sousa 587471ab54 AP_InertialSensor: disable I2C on MPU9250
As the datasheet says: "To prevent switching into I2C mode when using
SPI, the I2C interface should be disabled by setting the I2C_IF_DIS
configuration bit."

We also reset the sensor like PX4Firmware does for initializing the
MPU6000.  See: ee1d8cd770/src/drivers/mpu6000/mpu6000.cpp (L695)
2015-06-22 17:45:20 +10:00
Lucas De Marchi 3aa46e3213 AP_InertialSensor: use functor macros
Functor is not yet being used but let's make is macro fallback to the
previous Delegate implementation for easy of transition between the two.
2015-05-26 13:46:53 +10:00
Andrew Tridgell 007b01533d AP_InertialSensor: switched to 16g accel range for MPU9250
this matches the Pixhawk, and makes us less prone to vibration. We
have seen clipping at 8g
2015-04-28 15:30:29 +10:00
Andrew Tridgell 520c7c1306 AP_InertialSensor: always allow for AK8963 on MPU9250 2015-03-13 18:46:17 +11:00
Andrew Tridgell 60b8736cf1 AP_InertialSensor: use right AK8963 compass defines 2015-03-13 18:46:15 +11:00
Andrew Tridgell 808c33d0a7 AP_InertialSensor: support both MPU9250 and MPU9255
seems to be just different WHOAMI register
2015-03-13 13:26:49 +11:00
Andrew Tridgell 3d7d46b9b0 AP_InertialSensor: replaced INS_MPU6K_FILTER with INS_ACCEL_FILTER and INS_GYRO_FILTER
this allows filtering to be set separately on accels and gyros where possible
2015-03-12 12:50:31 +11:00
Jonathan Challinger 155c173ed1 AP_InertialSensor: rename _rotate_and_offset to _publish 2015-03-12 12:50:27 +11:00
Jonathan Challinger 502446d821 AP_InertialSensor: use LowPassFilter2pVector3f 2015-03-12 12:50:27 +11:00
mirkix fa950a735e AP_InertialSensor: add support for BBBMINI, simple ArduPilot DIY Cape for the BeagleBone Black 2015-01-12 21:36:40 +13:00
Andrew Tridgell 1b3c3c754d AP_InertialSensor: use correct ifdef for AK8963 2015-01-07 11:58:05 +11:00
Staroselskii Georgii f7f9cd2173 AP_InertialSensor: prevented MPU9250 from disabling I2C slaves 2015-01-07 08:41:13 +11:00
Andrew Tridgell 3518cf5480 AP_InertialSensor: fixed default MPU9250 orientation for NavIO 2014-11-04 16:18:35 +11:00
Andrew Tridgell a047d1f569 AP_InertialSensor: moved default filter and sample_rate to frontend
this simplifies the backends and prevents code repitition
2014-10-24 12:10:40 +11:00
Andrew Tridgell 3a9a5a9c18 AP_InertialSensor: implement gyro and accel health monitoring
sensor is healthy if it gave a sample on the last update()
2014-10-24 12:10:39 +11:00
Andrew Tridgell 586fa9a816 AP_InertialSensor: added product_id support
fill in parameter from first backend
2014-10-24 12:10:39 +11:00
Andrew Tridgell dcef9bb3b8 AP_InertialSensor: converted the MPU9250 driver to new API 2014-10-24 12:10:37 +11:00
Andrew Tridgell dcdb53584b AP_InertialSensor: use lockless structures in MPU9250 driver
this avoids suspending timers when transferring data between main
thread and SPI read thread
2014-08-22 21:13:11 +10:00
Andrew Tridgell a14f8dbd0a AP_InertialSensor_MPU9250: use micros64() and millis64() 2014-08-20 08:02:34 +10:00
Andrew Tridgell 3c2ab31415 AP_InertialSensor: get rid of data_ready for MPU9250
when running off a 1kHz timer and reading at 1kHz it is better to
double sample than it is to skip a sample, as skipping samples will
throw the filter off, whereas a double sample will have minimal effect
2014-08-19 20:03:33 +10:00
Andrew Tridgell 9e01c657e5 AP_InertialSensor: update MPU9250 driver for 1kHz operation
use a time base sample wait, with 1kHz sampling
2014-08-19 20:03:33 +10:00
Andrew Tridgell 50068a7c6a AP_InertialSensor: fixed default orientation for PXF board MPU9250 2014-08-19 10:08:16 +10:00
Víctor Mayoral Vilches 5e5319e23b AP_InertialSensor: MPU9250 cleaning 2014-08-19 10:08:16 +10:00
Mikhail Avkhimenia 34da221c3d AP_InertialSensor: Use MPU9250 DRDY pin only on boards that support it 2014-08-12 22:13:00 +10:00
Andrew Tridgell d1ba78002d AP_InertialSensor: added paranoid check for DRDY pin 2014-07-14 09:44:36 +10:00
Andrew Tridgell 6f9965cc22 AP_InertialSensor: fixed setup of DRDY pin on MPU9250 2014-07-14 09:44:36 +10:00
Andrew Tridgell 6a6dbe5790 AP_InertialSensor: added check for WHOAMI on MPU9250 2014-07-14 09:44:35 +10:00
Andrew Tridgell abb53eb9a2 AP_InertialSensor: simplify using HAL board subtypes 2014-07-14 09:44:35 +10:00
Andrew Tridgell 848b563fc3 AP_InertialSensor: rotate acccel/gyro for PXF 2014-07-14 09:44:34 +10:00
Víctor Mayoral Vilches aa60a89cda AP_InertialSensor_MPU9250: Fix SPI CS. 2014-07-14 09:29:45 +10:00
Víctor Mayoral Vilches 5e7e28a83e AP_InertialSensor_MPU9250.cpp: Update the DRDY pin. 2014-07-14 09:29:18 +10:00
Víctor Mayoral Vilches fac3d1c271 AP_InertialSensor_MPU9250: SPI userspace sensor driver.
InvenSense MPU9250 sensor driver and test code (available under
libraries/examples/).
2014-07-14 09:02:47 +10:00