Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
27 #ifndef IMU_H
28 #define IMU_H
29 
30 #include "math/pprz_algebra_int.h"
33 #include "generated/airframe.h"
34 
35 
37 struct Imu {
38  struct Int32Rates gyro;
39  struct Int32Vect3 accel;
40  struct Int32Vect3 mag;
50 
55 };
56 
58 extern struct Imu imu;
59 
60 /* underlying hardware */
61 #ifdef IMU_TYPE_H
62 #include IMU_TYPE_H
63 #endif
64 
65 extern void imu_init(void);
66 extern void imu_SetBodyToImuPhi(float phi);
67 extern void imu_SetBodyToImuTheta(float theta);
68 extern void imu_SetBodyToImuPsi(float psi);
69 extern void imu_SetBodyToImuCurrent(float set);
70 extern void imu_ResetBodyToImu(float reset);
71 
72 /* can be provided implementation */
73 extern void imu_scale_gyro(struct Imu *_imu);
74 extern void imu_scale_accel(struct Imu *_imu);
75 extern void imu_scale_mag(struct Imu *_imu);
76 
77 #if !defined IMU_BODY_TO_IMU_PHI && !defined IMU_BODY_TO_IMU_THETA && !defined IMU_BODY_TO_IMU_PSI
78 #define IMU_BODY_TO_IMU_PHI 0
79 #define IMU_BODY_TO_IMU_THETA 0
80 #define IMU_BODY_TO_IMU_PSI 0
81 #endif
82 
83 #if !defined IMU_GYRO_P_NEUTRAL && !defined IMU_GYRO_Q_NEUTRAL && !defined IMU_GYRO_R_NEUTRAL
84 #define IMU_GYRO_P_NEUTRAL 0
85 #define IMU_GYRO_Q_NEUTRAL 0
86 #define IMU_GYRO_R_NEUTRAL 0
87 #endif
88 
89 #if !defined IMU_ACCEL_X_NEUTRAL && !defined IMU_ACCEL_Y_NEUTRAL && !defined IMU_ACCEL_Z_NEUTRAL
90 #define IMU_ACCEL_X_NEUTRAL 0
91 #define IMU_ACCEL_Y_NEUTRAL 0
92 #define IMU_ACCEL_Z_NEUTRAL 0
93 #endif
94 
95 #if !defined IMU_GYRO_P_SIGN & !defined IMU_GYRO_Q_SIGN & !defined IMU_GYRO_R_SIGN
96 #define IMU_GYRO_P_SIGN 1
97 #define IMU_GYRO_Q_SIGN 1
98 #define IMU_GYRO_R_SIGN 1
99 #endif
100 #if !defined IMU_ACCEL_X_SIGN & !defined IMU_ACCEL_Y_SIGN & !defined IMU_ACCEL_Z_SIGN
101 #define IMU_ACCEL_X_SIGN 1
102 #define IMU_ACCEL_Y_SIGN 1
103 #define IMU_ACCEL_Z_SIGN 1
104 #endif
105 #if !defined IMU_MAG_X_SIGN & !defined IMU_MAG_Y_SIGN & !defined IMU_MAG_Z_SIGN
106 #define IMU_MAG_X_SIGN 1
107 #define IMU_MAG_Y_SIGN 1
108 #define IMU_MAG_Z_SIGN 1
109 #endif
110 
111 
112 #endif /* IMU_H */
void imu_SetBodyToImuCurrent(float set)
Definition: imu.c:178
angular rates
void reset(void)
void imu_SetBodyToImuTheta(float theta)
Definition: imu.c:160
struct Int32Vect3 accel_neutral
static accelerometer bias from calibration in raw/unscaled units
Definition: imu.h:44
struct Int32Rates gyro_prev
previous gyroscope measurements
Definition: imu.h:41
bool b2i_set_current
flag for adjusting body_to_imu via settings.
Definition: imu.h:54
void imu_SetBodyToImuPsi(float psi)
Definition: imu.c:169
void imu_ResetBodyToImu(float reset)
struct Int32Rates gyro_neutral
static gyroscope bias from calibration in raw/unscaled units
Definition: imu.h:43
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
Definition: imu.h:48
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:46
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
Definition: imu.h:39
void imu_scale_gyro(struct Imu *_imu)
Definition: ahrs_gx3.c:349
Paparazzi floating point algebra.
struct Imu imu
global IMU state
Definition: imu.c:108
void imu_scale_mag(struct Imu *_imu)
Definition: ahrs_gx3.c:351
struct Int32Vect3 mag_neutral
magnetometer neutral readings (bias) in raw/unscaled units
Definition: imu.h:45
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
Definition: imu.h:40
struct OrientationReps body_to_imu
rotation from body to imu frame
Definition: imu.h:49
void imu_SetBodyToImuPhi(float phi)
Definition: imu.c:151
struct Int32Vect3 accel_prev
previous accelerometer measurements
Definition: imu.h:42
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:47
void imu_scale_accel(struct Imu *_imu)
Definition: ahrs_gx3.c:350
abstract IMU interface providing fixed point interface
Definition: imu.h:37
Generic orientation representation and conversions.
void imu_init(void)
Definition: imu.c:110
Paparazzi fixed point algebra.
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC
Definition: imu.h:38