Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ahrs.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2010 The Paparazzi Team
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 
26 #ifndef AHRS_H
27 #define AHRS_H
28 
29 #include "std.h"
30 #include "math/pprz_algebra_int.h"
32 
33 #define AHRS_UNINIT 0
34 #define AHRS_RUNNING 1
35 
36 /* underlying includes (needed for parameters) */
37 #ifdef AHRS_TYPE_H
38 #include AHRS_TYPE_H
39 #endif
40 
42 struct Ahrs {
43 
48 
53 
55 };
56 
58 struct AhrsFloat {
65 
71 
72  // always use status from fixed point ahrs struct for now
73  //uint8_t status;
74 };
75 
77 extern struct Ahrs ahrs;
79 extern struct AhrsFloat ahrs_float;
80 
81 extern float ahrs_mag_offset;
82 
83 #define AHRS_FLOAT_OF_INT32() { \
84  QUAT_FLOAT_OF_BFP(ahrs_float.ltp_to_body_quat, ahrs.ltp_to_body_quat); \
85  EULERS_FLOAT_OF_BFP(ahrs_float.ltp_to_body_euler, ahrs.ltp_to_body_euler); \
86  RATES_FLOAT_OF_BFP(ahrs_float.body_rate, ahrs.body_rate); \
87  }
88 
89 #define AHRS_INT_OF_FLOAT() { \
90  QUAT_BFP_OF_REAL(ahrs.ltp_to_body_quat, ahrs_float.ltp_to_body_quat); \
91  EULERS_BFP_OF_REAL(ahrs.ltp_to_body_euler, ahrs_float.ltp_to_body_euler); \
92  RMAT_BFP_OF_REAL(ahrs.ltp_to_body_rmat, ahrs_float.ltp_to_body_rmat); \
93  RATES_BFP_OF_REAL(ahrs.body_rate, ahrs_float.body_rate); \
94  }
95 
96 #define AHRS_IMU_INT_OF_FLOAT() { \
97  QUAT_BFP_OF_REAL(ahrs.ltp_to_imu_quat, ahrs_float.ltp_to_imu_quat); \
98  EULERS_BFP_OF_REAL(ahrs.ltp_to_imu_euler, ahrs_float.ltp_to_imu_euler); \
99  RMAT_BFP_OF_REAL(ahrs.ltp_to_imu_rmat, ahrs_float.ltp_to_imu_rmat); \
100  RATES_BFP_OF_REAL(ahrs.imu_rate, ahrs_float.imu_rate); \
101  }
102 
106 extern void ahrs_init(void);
107 
112 extern void ahrs_align(void);
113 
118 extern void ahrs_propagate(void);
119 
124 extern void ahrs_update_accel(void);
125 
130 extern void ahrs_update_mag(void);
131 extern void ahrs_update_gps(void);
132 
133 #endif /* AHRS_H */
float ahrs_mag_offset
Definition: ahrs.c:27
struct Int32Rates body_rate
Rotational velocity in body frame.
Definition: ahrs.h:52
struct FloatRates body_rate_d
Definition: ahrs.h:70
struct FloatRMat ltp_to_body_rmat
Rotation from LocalTangentPlane to body frame as Rotation Matrix.
Definition: ahrs.h:68
struct FloatQuat ltp_to_imu_quat
Rotation from LocalTangentPlane to IMU frame as unit quaternion.
Definition: ahrs.h:59
rotation matrix
void ahrs_update_accel(void)
Update AHRS state with accerleration measurements.
struct Ahrs ahrs
global AHRS state (fixed point version)
Definition: ahrs.c:24
struct AhrsFloat ahrs_float
global AHRS state (floating point version)
Definition: ahrs.c:25
struct FloatRMat ltp_to_imu_rmat
Rotation from LocalTangentPlane to IMU frame as Rotation Matrix.
Definition: ahrs.h:61
angular rates
Rotation quaternion.
struct Int32Rates imu_rate
Rotational velocity in IMU frame.
Definition: ahrs.h:47
euler angles
void ahrs_update_gps(void)
struct Int32RMat ltp_to_body_rmat
Rotation from LocalTangentPlane to body frame as Rotation Matrix.
Definition: ahrs.h:51
struct Int32Quat ltp_to_imu_quat
Rotation from LocalTangentPlane to IMU frame as unit quaternion.
Definition: ahrs.h:44
Roation quaternion.
Paparazzi floating point algebra.
void ahrs_propagate(void)
Propagation.
void ahrs_init(void)
AHRS initialization.
Definition: ins_xsens.c:75
struct FloatQuat ltp_to_body_quat
Rotation from LocalTangentPlane to body frame as unit quaternion.
Definition: ahrs.h:66
uint8_t status
status of the AHRS, AHRS_UNINIT or AHRS_RUNNING
Definition: ahrs.h:54
struct Int32Quat ltp_to_body_quat
Rotation from LocalTangentPlane to body frame as unit quaternion.
Definition: ahrs.h:49
struct FloatRates imu_rate_previous
Definition: ahrs.h:63
Attitude and Heading Reference System state (fixed point version)
Definition: ahrs.h:42
angular rates
struct FloatRates imu_rate
Rotational velocity in IMU frame.
Definition: ahrs.h:62
struct Int32Eulers ltp_to_body_euler
Rotation from LocalTangentPlane to body frame as Euler angles.
Definition: ahrs.h:50
unsigned char uint8_t
Definition: types.h:14
struct Int32Eulers ltp_to_imu_euler
Rotation from LocalTangentPlane to IMU frame as Euler angles.
Definition: ahrs.h:45
struct FloatEulers ltp_to_body_euler
Rotation from LocalTangentPlane to body frame as Euler angles.
Definition: ahrs.h:67
Attitude and Heading Reference System state (floating point version)
Definition: ahrs.h:58
struct FloatRates imu_rate_d
Definition: ahrs.h:64
void ahrs_align(void)
Aligns the AHRS.
void ahrs_update_mag(void)
Update AHRS state with magnetometer measurements.
rotation matrix
struct FloatRates body_rate
Rotational velocity in body frame.
Definition: ahrs.h:69
struct Int32RMat ltp_to_imu_rmat
Rotation from LocalTangentPlane to IMU frame as Rotation Matrix.
Definition: ahrs.h:46
Paparazzi fixed point algebra.
struct FloatEulers ltp_to_imu_euler
Rotation from LocalTangentPlane to IMU frame as Euler angles.
Definition: ahrs.h:60
euler angles