MAV'RIC
imu.h
1 /*******************************************************************************
2  * Copyright (c) 2009-2014, MAV'RIC Development Team
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  ******************************************************************************/
31 
32 /*******************************************************************************
33  * \file imu.h
34  *
35  * \author MAV'RIC Team
36  * \author Felix Schill
37  * \author Gregoire Heitz
38  *
39  * \brief This file implements the IMU data structure
40  *
41  ******************************************************************************/
42 
43 
44 #ifndef IMU_H_
45 #define IMU_H_
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 #include <stdint.h>
52 #include <stdbool.h>
53 #include "gyroscope.h"
54 #include "accelerometer.h"
55 #include "magnetometer.h"
56 #include "quaternions.h"
57 #include "scheduler.h"
58 #include "state.h"
59 
60 #define GYRO_LPF 0.1f
61 #define ACC_LPF 0.05f
62 #define MAG_LPF 0.1f
63 
64 
68 typedef struct
69 {
70  float bias[3];
71  float scale_factor[3];
72  float orientation[3];
73  uint8_t axis[3];
74 
75  float max_oriented_values[3];
76  float min_oriented_values[3];
77  bool calibration;
79 
80 
85 typedef struct
86 {
87  float bias[3];
88  float scale_factor[3];
89  float orientation[3];
90  uint8_t axis[3];
92 
93 
97 typedef struct
98 {
102 }imu_conf_t;
103 
104 
108 typedef struct
109 {
113 
117 
121 
125 
126  float dt;
127  uint32_t last_update;
129 
131 } imu_t;
132 
133 
143 bool imu_init (imu_t *imu, imu_conf_t *conf_imu, state_t* state);
144 
145 
151 void imu_calibrate_gyros(imu_t *imu);
152 
153 
159 void imu_update(imu_t *imu);
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif /* IMU_H_ */
accelerometer_t oriented_accelero
The accelerometer oriented values structure.
Definition: imu.h:119
magnetometer_t scaled_compass
The compass scaled values structure.
Definition: imu.h:124
sensor_calib_t calib_accelero
The accelerometer calibration structure.
Definition: imu.h:111
The magnetometer structure.
Definition: magnetometer.h:49
sensor_calib_t calib_gyro
The gyroscope calibration structure.
Definition: imu.h:110
state_t * state
The pointer to the state structure.
Definition: imu.h:130
gyroscope_t oriented_gyro
The gyroscope oriented values structure.
Definition: imu.h:115
bool calibration
In calibration mode, true.
Definition: imu.h:77
The gyroscope structure.
Definition: gyroscope.h:50
Structure containing the configuration accelero, gyro and magnetometer sensors' gains.
Definition: imu.h:85
sensor_config_t magnetometer
The compass configuration structure.
Definition: imu.h:101
sensor_config_t gyroscope
The accelerometer configuration structure.
Definition: imu.h:100
float dt
The time interval between two IMU updates.
Definition: imu.h:126
The configuration IMU structure.
Definition: imu.h:97
accelerometer_t scaled_accelero
The accelerometer scaled values structure.
Definition: imu.h:120
uint8_t calibration_level
The level of calibration.
Definition: imu.h:128
uint32_t last_update
The time of the last IMU update in ms.
Definition: imu.h:127
magnetometer_t raw_compass
The compass raw values structure.
Definition: imu.h:122
The IMU structure.
Definition: imu.h:108
gyroscope_t scaled_gyro
The gyroscope scaled values structure.
Definition: imu.h:116
Accelerometer structure.
Definition: accelerometer.h:49
The state structure.
Definition: state.h:79
magnetometer_t oriented_compass
The compass oriented values structure.
Definition: imu.h:123
sensor_calib_t calib_compass
The compass calibration structure.
Definition: imu.h:112
Structure containing the accelero, gyro and magnetometer sensors' gains.
Definition: imu.h:68
accelerometer_t raw_accelero
The accelerometer raw values structure.
Definition: imu.h:118
gyroscope_t raw_gyro
The gyroscope raw values structure.
Definition: imu.h:114
sensor_config_t accelerometer
The gyroscope configuration structure.
Definition: imu.h:99