ISF  2.1
Intelligent Sensing Framework for Kinetis with Processor Expert
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fusion_types.h
Go to the documentation of this file.
1 /*
2  * fusion_types.h
3  *
4  * Created on: Nov 25, 2014
5  * Author: B37804
6  */
7 
8 #ifndef FUSION_TYPES_H_
9 #define FUSION_TYPES_H_
10 
11 #include "matrix.h"
12 
13 // coordinate system for the build
14 #define NED 0 // identifier for NED angle output
15 #define ANDROID 1 // identifier for Andro
16 #define WIN8 2 // identifier for Windows 8 angle output
17 // type definitions
18 
19 // the quaternion type to be transmitted
21 
22 
23 // structure definitions
24 
25 
26 // quaternion structure definition
28 {
29  float q0; // scalar component
30  float q1; // x vector component
31  float q2; // y vector component
32  float q3; // z vector component
33 };
34 
35 
36 // 1DOF pressure state vector structure
38 {
39  float fLPHp; // low pass filtered height (m)
40  float fLPTp; // low pass filtered temperature (C);
41  float fdeltat; // time interval (s)
42  float flpf; // low pass filter coefficient
43  int32 systick; // systick timer
44  int8 resetflag; // flag to request re-initialization on next pass
45 };
46 
47 // 3DOF basic accelerometer state vector structure
49 {
50  // start: elements common to all motion state vectors
51  // Euler angles
52  float fLPPhi; // low pass roll (deg)
53  float fLPThe; // low pass pitch (deg)
54  float fLPPsi; // low pass yaw (deg)
55  float fLPRho; // low pass compass (deg)
56  float fLPChi; // low pass tilt from vertical (deg)
57  // orientation matrix, quaternion and rotation vector
58  float fLPR[3][3]; // low pass filtered orientation matrix
59  struct fquaternion fLPq; // low pass filtered orientation quaternion
60  float fLPRVec[3]; // rotation vector
61  // angular velocity
62  float fOmega[3]; // angular velocity (deg/s)
63  // systick timer for benchmarking
64  int32 systick; // systick timer
65  // end: elements common to all motion state vectors
66  float fR[3][3]; // unfiltered orientation matrix
67  struct fquaternion fq; // unfiltered orientation quaternion
68  float fdeltat; // time interval (s)
69  float flpf; // low pass filter coefficient
70  int8 resetflag; // flag to request re-initialization on next pass
71 };
72 
73 // 3DOF basic magnetometer state vector structure
75 {
76  // start: elements common to all motion state vectors
77  // Euler angles
78  float fLPPhi; // low pass roll (deg)
79  float fLPThe; // low pass pitch (deg)
80  float fLPPsi; // low pass yaw (deg)
81  float fLPRho; // low pass compass (deg)
82  float fLPChi; // low pass tilt from vertical (deg)
83  // orientation matrix, quaternion and rotation vector
84  float fLPR[3][3]; // low pass filtered orientation matrix
85  struct fquaternion fLPq; // low pass filtered orientation quaternion
86  float fLPRVec[3]; // rotation vector
87  // angular velocity
88  float fOmega[3]; // angular velocity (deg/s)
89  // systick timer for benchmarking
90  int32 systick; // systick timer
91  // end: elements common to all motion state vectors
92  float fR[3][3]; // unfiltered orientation matrix
93  struct fquaternion fq; // unfiltered orientation quaternion
94  float fdeltat; // time interval (s)
95  float flpf; // low pass filter coefficient
96  int8 resetflag; // flag to request re-initialization on next pass
97 };
98 
99 // 3DOF basic gyroscope state vector structure
101 {
102  // start: elements common to all motion state vectors
103  // Euler angles
104  float fPhi; // roll (deg)
105  float fThe; // pitch (deg)
106  float fPsi; // yaw (deg)
107  float fRho; // compass (deg)
108  float fChi; // tilt from vertical (deg)
109  // orientation matrices and quaternions
110  float fR[3][3]; // unfiltered orientation matrix
111  struct fquaternion fq; // unfiltered orientation quaternion
112  float fRVec[3]; // rotation vector
113  // angular velocity
114  float fOmega[3]; // angular velocity (deg/s)
115  // systick timer for benchmarking
116  int32 systick; // systick timer
117  // end: elements common to all motion state vectors
118  struct fquaternion fDeltaq; // delta rotation quaternion
119  float fFastdeltat; // sensor sampling interval (s) = 1 / SENSORFS
120  float fdeltat; // kalman filter sampling interval (s) = OVERSAMPLE_RATIO / SENSORFS
121  int8 resetflag; // flag to request re-initialization on next pass
122 };
123 
124 // 6DOF basic accelerometer and magnetometer state vector structure
126 {
127  // start: elements common to all motion state vectors
128  // Euler angles
129  float fLPPhi; // low pass roll (deg)
130  float fLPThe; // low pass pitch (deg)
131  float fLPPsi; // low pass yaw (deg)
132  float fLPRho; // low pass compass (deg)
133  float fLPChi; // low pass tilt from vertical (deg)
134  // orientation matrix, quaternion and rotation vector
135  float fLPR[3][3]; // low pass filtered orientation matrix
136  struct fquaternion fLPq; // low pass filtered orientation quaternion
137  float fLPRVec[3]; // rotation vector
138  // angular velocity
139  float fOmega[3]; // virtual gyro angular velocity (deg/s)
140  // systick timer for benchmarking
141  int32 systick; // systick timer
142  // end: elements common to all motion state vectors
143  float fR[3][3]; // unfiltered orientation matrix
144  struct fquaternion fq; // unfiltered orientation quaternion
145  float fDelta; // unfiltered inclination angle (deg)
146  float fLPDelta; // low pass filtered inclination angle (deg)
147  float fdeltat; // time interval (s)
148  float flpf; // low pass filter coefficient
149  int8 resetflag; // flag to request re-initialization on next pass
150 };
151 
152 // 6DOF Kalman filter accelerometer and gyroscope state vector structure
154 {
155  // start: elements common to all motion state vectors
156  // Euler angles
157  float fPhiPl; // roll (deg)
158  float fThePl; // pitch (deg)
159  float fPsiPl; // yaw (deg)
160  float fRhoPl; // compass (deg)
161  float fChiPl; // tilt from vertical (deg)
162  // orientation matrix, quaternion and rotation vector
163  float fRPl[3][3]; // a posteriori rotation matrix
164  struct fquaternion fqPl; // a posteriori orientation quaternion
165  float fRVecPl[3]; // rotation vector
166  // angular velocity
167  float fOmega[3]; // angular velocity (deg/s)
168  // systick timer for benchmarking
169  int32 systick; // systick timer
170  // end: elements common to all motion state vectors
171 
172  // elements transmitted over bluetooth in kalman packet
173  float fbPl[3]; // gyro offset (deg/s)
174  float fThErrPl[3]; // orientation error (deg)
175  float fbErrPl[3]; // gyro offset error (deg/s)
176  // end elements transmitted in kalman packet
177 
178  float fzErrMi[3]; // angular error (deg) between a priori and eCompass orientations
179  float fRMi[3][3]; // a priori rotation matrix
180  struct fquaternion fqMi; // a priori orientation quaternion
181  struct fquaternion fDeltaq; // delta a priori or a posteriori quaternion
182  float faSePl[3]; // linear acceleration (g, sensor frame)
183  float faErrSePl[3]; // linear acceleration error (g, sensor frame)
184  float fgErrSeMi[3]; // difference (g, sensor frame) of gravity vector (accel) and gravity vector (gyro)
185  float fgSeGyMi[3]; // gravity vector (g, sensor frame) measurement from gyro
186  float faSeMi[3]; // linear acceleration (g, sensor frame)
187  float fQvAA; // accelerometer terms of Qv
188  float fPPlus9x9[9][9]; // covariance matrix P+
189  float fK9x3[9][3]; // kalman filter gain matrix K
190  float fQw9x9[9][9]; // covariance matrix Qw
191  float fC3x9[3][9]; // measurement matrix C
192  float fcasq; // FCA * FCA;
193  float fFastdeltat; // sensor sampling interval (s) = 1 / SENSORFS
194  float fdeltat; // kalman filter sampling interval (s) = OVERSAMPLE_RATIO / SENSORFS
195  float fdeltatsq; // fdeltat * fdeltat;
196  float fQwbplusQvG; // FQWB + FQVG;
197  int16 iFirstOrientationLock; // denotes that 6DOF orientation has locked to 3DOF
198  int8 resetflag; // flag to request re-initialization on next pass
199 };
200 
201 // 9DOF Kalman filter accelerometer, magnetometer and gyroscope state vector structure
203 {
204  // start: elements common to all motion state vectors
205  // Euler angles
206  float fPhiPl; // roll (deg)
207  float fThePl; // pitch (deg)
208  float fPsiPl; // yaw (deg)
209  float fRhoPl; // compass (deg)
210  float fChiPl; // tilt from vertical (deg)
211  // orientation matrix, quaternion and rotation vector
212  float fRPl[3][3]; // a posteriori orientation matrix
213  struct fquaternion fqPl; // a posteriori orientation quaternion
214  float fRVecPl[3]; // rotation vector
215  // angular velocity
216  float fOmega[3]; // angular velocity (deg/s)
217  // systick timer for benchmarking
218  int32 systick; // systick timer;
219  // end: elements common to all motion state vectors
220 
221  // elements transmitted over bluetooth in kalman packet
222  float fbPl[3]; // gyro offset (deg/s)
223  float fThErrPl[3]; // orientation error (deg)
224  float fbErrPl[3]; // gyro offset error (deg/s)
225  // end elements transmitted in kalman packet
226 
227  float fdErrGlPl[3]; // magnetic disturbance error (uT, global frame)
228  float fdErrSePl[3]; // magnetic disturbance error (uT, sensor frame)
229  float faErrSePl[3]; // linear acceleration error (g, sensor frame)
230  float faSeMi[3]; // linear acceleration (g, sensor frame)
231  float fDeltaPl; // inclination angle (deg)
232  float faSePl[3]; // linear acceleration (g, sensor frame)
233  float faGlPl[3]; // linear acceleration (g, global frame)
234  float fgErrSeMi[3]; // difference (g, sensor frame) of gravity vector (accel) and gravity vector (gyro)
235  float fmErrSeMi[3]; // difference (uT, sensor frame) of geomagnetic vector (magnetometer) and geomagnetic vector (gyro)
236  float fgSeGyMi[3]; // gravity vector (g, sensor frame) measurement from gyro
237  float fmSeGyMi[3]; // geomagnetic vector (uT, sensor frame) measurement from gyro
238  float fmGl[3]; // geomagnetic vector (uT, global frame)
239  float fQvAA; // accelerometer terms of Qv
240  float fQvMM; // magnetometer terms of Qv
241  float fPPlus12x12[12][12]; // covariance matrix P+
242  float fK12x6[12][6]; // kalman filter gain matrix K
243  float fQw12x12[12][12]; // covariance matrix Qw
244  float fC6x12[6][12]; // measurement matrix C
245  float fRMi[3][3]; // a priori orientation matrix
246  struct fquaternion fDeltaq; // delta quaternion
247  struct fquaternion fqMi; // a priori orientation quaternion
248  float fcasq; // FCA * FCA;
249  float fcdsq; // FCD * FCD;
250  float fFastdeltat; // sensor sampling interval (s) = 1 / SENSORFS
251  float fdeltat; // kalman filter sampling interval (s) = OVERSAMPLE_RATIO / SENSORFS
252  float fdeltatsq; // fdeltat * fdeltat
253  float fQwbplusQvG; // FQWB + FQVG
254  int16 iFirstOrientationLock; // denotes that 9DOF orientation has locked to 6DOF
255  int8 resetflag; // flag to request re-initialization on next pass
256 };
257 
258 typedef struct {
259  uint32 outputDataRate; /* time in usecs between orientation output samples */
260  uint8 coordinateSystem; /* use CoordinateSystem_t enums */
261  uint8 accelOversampleRatio; /* number of accel samples to take per orientation output */
262  uint8 magOversampleRatio; /* number of mag samples to take per orientation output */
263  uint8 gyroOversampleRatio; /* number of gyro samples to take per orientation output */
265 
266 #endif /* FUSION_TYPES_H_ */
int16 iFirstOrientationLock
Definition: fusion_types.h:197
float fLPRVec[3]
Definition: fusion_types.h:86
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
struct fquaternion fLPq
Definition: fusion_types.h:59
float fRMi[3][3]
Definition: fusion_types.h:179
float fR[3][3]
Definition: fusion_types.h:143
struct fquaternion fqMi
Definition: fusion_types.h:247
float fPPlus9x9[9][9]
Definition: fusion_types.h:188
quaternion
Definition: fusion_types.h:20
float fC6x12[6][12]
Definition: fusion_types.h:244
float fRPl[3][3]
Definition: fusion_types.h:163
float fRPl[3][3]
Definition: fusion_types.h:212
struct fquaternion fDeltaq
Definition: fusion_types.h:246
float fQw12x12[12][12]
Definition: fusion_types.h:243
struct fquaternion fqPl
Definition: fusion_types.h:213
struct fquaternion fDeltaq
Definition: fusion_types.h:181
float fLPRVec[3]
Definition: fusion_types.h:60
struct fquaternion fq
Definition: fusion_types.h:93
signed char int8
Definition: basic_types.h:12
struct fquaternion fq
Definition: fusion_types.h:67
struct fquaternion fLPq
Definition: fusion_types.h:85
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
enum quaternion quaternion_type
float fLPR[3][3]
Definition: fusion_types.h:84
struct fquaternion fqPl
Definition: fusion_types.h:164
float fR[3][3]
Definition: fusion_types.h:110
float fR[3][3]
Definition: fusion_types.h:66
float fLPR[3][3]
Definition: fusion_types.h:135
float fR[3][3]
Definition: fusion_types.h:92
float fK12x6[12][6]
Definition: fusion_types.h:242
float fC3x9[3][9]
Definition: fusion_types.h:191
struct fquaternion fq
Definition: fusion_types.h:144
float fOmega[3]
Definition: fusion_types.h:88
float fLPR[3][3]
Definition: fusion_types.h:58
struct fquaternion fq
Definition: fusion_types.h:111
long int32
This defines int32 as long.
Definition: isf_types.h:32
float fRMi[3][3]
Definition: fusion_types.h:245
float fOmega[3]
Definition: fusion_types.h:62
float fQw9x9[9][9]
Definition: fusion_types.h:190
short int16
This defines int16 as short.
Definition: isf_types.h:23
struct fquaternion fqMi
Definition: fusion_types.h:180
float fPPlus12x12[12][12]
Definition: fusion_types.h:241
struct fquaternion fDeltaq
Definition: fusion_types.h:118
float fK9x3[9][3]
Definition: fusion_types.h:189
struct fquaternion fLPq
Definition: fusion_types.h:136