Commit Graph

188 Commits

Author SHA1 Message Date
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
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
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 7fef515555 AP_InertialSensor: unify delta angle calculation
This commit basically moves delta angle calculation that was previously done in
AP_InertialSensor_PX4 to a common place. Instances must publish their gyro raw
sample rate to enable delta angle calculation.
2015-10-22 16:53:11 +11:00
Gustavo Jose de Sousa 9e05041234 AP_InertialSensor: allow publishing gyro raw sample rate to frontend
That information will be used for a unified delta angle calculation.
2015-10-22 16:53:11 +11:00
Gustavo Jose de Sousa 75fdac648f AP_InertialSensor: unify delta velocity calculation
This commit basically moves delta velocity calculation that was previously done
in AP_InertialSensor_PX4 to a common place. Instances must publish their accel
raw sample rate to enable delta velocity calculation.
2015-10-22 16:53:10 +11:00
Lucas De Marchi 30a50b362f AP_InertialSensor: remove check for vibe check
For all supported boards we have vibration check.
2015-10-21 10:05:17 +11:00
Lucas De Marchi db62e55753 AP_InertialSensor: remove check for max INS instances
For all supported boards the maximum number of instances is 3.
2015-10-21 10:05:17 +11:00
Randy Mackay b751d2bb18 InertialSensor: remove gyro cal on first arming 2015-10-19 12:00:38 +09:00
José Roberto de Souza daa32725ac AP_InertialSensor: Fix typo: auxiliar to auxiliary 2015-10-16 10:16:24 +11:00
mirkix 840f583d23 AP_InertialSensor: Add MPU9250 multiple instance support 2015-09-24 13:11:38 +10:00
Randy Mackay ec82aa68c4 InertialSensor: add GYR_CAL to control when gyro calibration occurs 2015-09-21 17:06:16 +09:00
raspilot 1421cf600a AP_InertialSensor: added support for raspilot 2015-09-14 14:22:15 +10:00
Gustavo Jose de Sousa 5329e63742 AP_InertialSensor: allow publishing sample rate to frontend
That information will be used for a "centralized" vibration calculation.
2015-09-07 11:14:42 +10:00
Lucas De Marchi c66800dfec AP_InertialSensor: add singleton interface
In order to allow other libraries to use the InertialSensor we need a
way to let them to get the only instance of InertialSensor. The
conventional way to do a singleton would be to let the constructor
private and force it to be instantiated from the get_instance() method.

Here however we just call panic() on the constructor if there's already
an instance alive. This allows us to let the vehicles as is. Later we
can change it so they call the get_instance() method instead.
2015-08-28 12:39:08 +10:00
Lucas De Marchi caae933c28 AP_InertialSensor: Add support for auxiliary buses
Add an AuxiliaryBus class that can be derived for specific
implementations in inertial sensor backends. It's an abstract
implementation so other libraries can use the auxiliary bus exported. In
order for this to succeed the backend implementation must split the
initialization of the sensor from the actual sample collecting, like is
done in MPU6000.

When AP_InertialSensor::get_auxiliary_bus() is called it will execute
following steps:
	a) Force the backends to be detected if it's the first time it's
	   being called
	b) Find the backend identified by the id
	c) call get_auxiliary_bus() on the backend so other libraries can
	   that AuxiliaryBus to initialize a slave device

Slave devices can be used by calling AuxiliaryBus::request_next_slave()
and are owned by the caller until AuxiliaryBus::register_periodic_read()
is called. From that time on the AuxiliaryBus object takes its ownership.
This way it's possible to do the necessary cleanup later without
introducing refcounts, that we don't have support to.

Between these 2 functions the caller can configure the slave device by
doing its specific initializations by calling the passthrough_*
functions. After the initial configuration and register_periodic_read()
is called only read() can be called.
2015-08-28 12:39:08 +10:00
Lucas De Marchi 7d9579c5d8 AP_InertialSensor: identify backend with ID
Identify backend with an id, allowing other libraries to connect to
them. This is different from the _product_id member because it
identifies the sensor, not the board the sensor is in, which is
meaningless for our use case.
2015-08-28 12:39:07 +10:00
Lucas De Marchi 22c787058e AP_InertialSensor: allow to split detection and initialization
This allows backends to have a separate detection and initialization
logic. It doesn't change any backend yet and with the current code
there's no change in behavior either. This only allows
AP_InertialSensor::_detect_backend() to be called earlier so
AP_InertialSensor object can be used by other libraries. If it's not
called, later on AP_InertialSensor::init() will detect and start all
backends.
2015-08-28 12:39:07 +10:00
ziltoid2 0b1a997800 AP_IntertialSensor: don't require acceleration calibration in hil mode 2015-08-23 16:48:48 +10:00
Tom Pittenger 2620a57700 AP_InertialSensor: Added is_still() check
very strict check that all axis are not vibrating much at all
new param: INS_STILL_THRESH used to be a vibration threshold for different platforms
// @Description: Threshold to tolerate vibration to determine if vehicle is motionless. This depends on the frame type and if there is a constant vibration due to motors before launch or after landing. Total motionless is about 0.05. Suggested values: Planes/rover use 0.1, multirotors use 1, tradHeli uses 5
2015-08-23 10:34:17 +10:00
Tom Pittenger 220163e269 AP_InertialSensor: correct USE param storage index
USE, USE2, USE3 have 20, 21, 21 but should be 20, 21, 22
2015-08-21 11:35:37 +09:00
Randy Mackay e5615ec349 INS: add USE parameters 2015-08-19 16:44:15 +09:00
Randy Mackay affbd67c43 InertialSensor: add vibration monitoring of 2nd IMU 2015-08-19 16:44:12 +09:00
Andrew Tridgell 980659d346 AP_InertialSensor: removed AVR1280 specific ifdef 2015-08-11 16:47:56 +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