Paparazzi UAS  v5.8.2_stable-0-g6260b7c
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 
36 extern void imu_impl_init(void);
38 extern void imu_periodic(void);
39 
41 struct Imu {
42  struct Int32Rates gyro;
43  struct Int32Vect3 accel;
44  struct Int32Vect3 mag;
54 
59 };
60 
62 extern struct Imu imu;
63 
64 /* underlying hardware */
65 #ifdef IMU_TYPE_H
66 #include IMU_TYPE_H
67 #endif
68 
69 extern void imu_init(void);
70 extern void imu_SetBodyToImuPhi(float phi);
71 extern void imu_SetBodyToImuTheta(float theta);
72 extern void imu_SetBodyToImuPsi(float psi);
73 extern void imu_SetBodyToImuCurrent(float set);
74 extern void imu_ResetBodyToImu(float reset);
75 
76 /* can be provided implementation */
77 extern void imu_scale_gyro(struct Imu *_imu);
78 extern void imu_scale_accel(struct Imu *_imu);
79 extern void imu_scale_mag(struct Imu *_imu);
80 
81 #if !defined IMU_BODY_TO_IMU_PHI && !defined IMU_BODY_TO_IMU_THETA && !defined IMU_BODY_TO_IMU_PSI
82 #define IMU_BODY_TO_IMU_PHI 0
83 #define IMU_BODY_TO_IMU_THETA 0
84 #define IMU_BODY_TO_IMU_PSI 0
85 #endif
86 
87 #if !defined IMU_GYRO_P_NEUTRAL && !defined IMU_GYRO_Q_NEUTRAL && !defined IMU_GYRO_R_NEUTRAL
88 #define IMU_GYRO_P_NEUTRAL 0
89 #define IMU_GYRO_Q_NEUTRAL 0
90 #define IMU_GYRO_R_NEUTRAL 0
91 #endif
92 
93 #if !defined IMU_ACCEL_X_NEUTRAL && !defined IMU_ACCEL_Y_NEUTRAL && !defined IMU_ACCEL_Z_NEUTRAL
94 #define IMU_ACCEL_X_NEUTRAL 0
95 #define IMU_ACCEL_Y_NEUTRAL 0
96 #define IMU_ACCEL_Z_NEUTRAL 0
97 #endif
98 
99 #if !defined IMU_GYRO_P_SIGN & !defined IMU_GYRO_Q_SIGN & !defined IMU_GYRO_R_SIGN
100 #define IMU_GYRO_P_SIGN 1
101 #define IMU_GYRO_Q_SIGN 1
102 #define IMU_GYRO_R_SIGN 1
103 #endif
104 #if !defined IMU_ACCEL_X_SIGN & !defined IMU_ACCEL_Y_SIGN & !defined IMU_ACCEL_Z_SIGN
105 #define IMU_ACCEL_X_SIGN 1
106 #define IMU_ACCEL_Y_SIGN 1
107 #define IMU_ACCEL_Z_SIGN 1
108 #endif
109 #if !defined IMU_MAG_X_SIGN & !defined IMU_MAG_Y_SIGN & !defined IMU_MAG_Z_SIGN
110 #define IMU_MAG_X_SIGN 1
111 #define IMU_MAG_Y_SIGN 1
112 #define IMU_MAG_Z_SIGN 1
113 #endif
114 
115 
116 #endif /* IMU_H */
void imu_SetBodyToImuCurrent(float set)
Definition: imu.c:179
angular rates
void reset(void)
void imu_SetBodyToImuTheta(float theta)
Definition: imu.c:161
struct Int32Vect3 accel_neutral
accelerometer bias
Definition: imu.h:48
struct Int32Rates gyro_prev
previous gyroscope measurements
Definition: imu.h:45
void imu_SetBodyToImuPsi(float psi)
Definition: imu.c:170
bool_t b2i_set_current
flag for adjusting body_to_imu via settings.
Definition: imu.h:58
void imu_ResetBodyToImu(float reset)
struct Int32Rates gyro_neutral
gyroscope bias
Definition: imu.h:47
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
Definition: imu.h:52
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:50
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
Definition: imu.h:43
void imu_scale_gyro(struct Imu *_imu)
Definition: ahrs_gx3.c:349
Paparazzi floating point algebra.
struct Imu imu
global IMU state
Definition: imu_aspirin2.c:43
void imu_scale_mag(struct Imu *_imu)
Definition: ahrs_gx3.c:351
struct Int32Vect3 mag_neutral
magnetometer neutral readings (bias)
Definition: imu.h:49
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
Definition: imu.h:44
struct OrientationReps body_to_imu
rotation from body to imu frame
Definition: imu.h:53
void imu_SetBodyToImuPhi(float phi)
Definition: imu.c:152
struct Int32Vect3 accel_prev
previous accelerometer measurements
Definition: imu.h:46
void imu_periodic(void)
optional.
Definition: imu_apogee.c:95
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:51
void imu_scale_accel(struct Imu *_imu)
Definition: ahrs_gx3.c:350
abstract IMU interface providing fixed point interface
Definition: imu.h:41
Generic orientation representation and conversions.
void imu_init(void)
Definition: imu.c:110
void imu_impl_init(void)
must be defined by underlying hardware
Definition: imu_apogee.c:79
Paparazzi fixed point algebra.
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC
Definition: imu.h:42