Sensor Fusion Library 0.6.1
Orientation sensing for Espressif (ESP32, ESP8266) processors
Loading...
Searching...
No Matches
sensor_fusion.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2017 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9// Sensor fusion requires a fairly extensive set of data structures, which are
10// defined in this file. The top level structure is shown near the bottom. The
11// size of this structure (SensorFusionGlobals) varies dramatically as a function
12// of which fusion variations have been selected in build.h.
13
18#ifndef SENSOR_FUSION_H
19#define SENSOR_FUSION_H
20
21#include <Arduino.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27// Standard includes
28#include <math.h>
29#include <stdbool.h>
30#include <stdint.h>
31#include <stdio.h>
32
33#include "board.h" // Hardware-specific details (e.g. particular sensor ICs)
34#include "build.h" // This is where the build parameters are defined
35#include "driver_sensors_types.h" // Typedefs for the sensor hardware
36#include "magnetic.h" // Magnetic calibration functions/structures
37#include "matrix.h" // Matrix math
38#include "orientation.h" // Functions for manipulating orientations
39#include "precisionAccelerometer.h" // Accel calibration functions/structures
40
50
54#define CHX 0
55#define CHY 1
56#define CHZ 2
58
59// booleans
60#ifndef true
61#define true 1
62#endif
63#ifndef false
64#define false 0
65#endif
66
70//#define B0 (1 << 0)
71//#define B1 (1 << 1)
72//#define B2 (1 << 2)
73//#define B3 (1 << 3)
75
79#ifndef PI
80 #define PI 3.141592654F
81#endif
82#define PIOVER2 1.570796327F
83#define FPIOVER180 0.01745329251994F
84#define F180OVERPI 57.2957795130823F
85#define F180OVERPISQ 3282.8063500117F
86#define ONETHIRD 0.33333333F
87#define ONESIXTH 0.166666667F
88#define ONESIXTEENTH 0.0625F
89#define ONEOVER12 0.083333333F
90#define ONEOVER48 0.02083333333F
91#define ONEOVER120 0.0083333333F
92#define ONEOVER3840 0.0002604166667F
93#define ONEOVERSQRT2 0.707106781F
94#define SQRT15OVER4 0.968245837F
95#define GTOMSEC2 9.80665
97
98// Placeholder structures (redefined later, but needed now for pointer definitions)
100struct StatusSubsystem;
101struct PhysicalSensor;
102struct ControlSubsystem;
103
114
115// declare typedefs for function prototypes that need to be installed
116typedef int8_t (initializeSensor_t) (
117 struct PhysicalSensor *sensor,
118 struct SensorFusionGlobals *sfg
119) ;
120typedef int8_t (readSensor_t) (
121 struct PhysicalSensor *sensor,
122 struct SensorFusionGlobals *sfg
123) ;
124typedef int8_t (readSensors_t) (
125 struct SensorFusionGlobals *sfg,
126 uint8_t read_loop_counter
127) ;
128typedef int8_t (installSensor_t) (
129 struct SensorFusionGlobals *sfg,
130 struct PhysicalSensor *sensor,
131 uint16_t addr,
132 uint16_t schedule,
134 initializeSensor_t *initialize,
135 readSensor_t *read
136);
137
138typedef void (initializeFusionEngine_t) (struct SensorFusionGlobals *sfg, int pin_i2c_sda1, int pin_i2c_scl);
139typedef void (runFusion_t) (struct SensorFusionGlobals *sfg);
140typedef void (clearFIFOs_t) (struct SensorFusionGlobals *sfg);
141typedef void (conditionSensorReadings_t) (struct SensorFusionGlobals *sfg);
142typedef void (applyPerturbation_t) (struct SensorFusionGlobals *sfg) ;
143typedef void (setStatus_t) (struct SensorFusionGlobals *sfg, fusion_status_t status);
144typedef fusion_status_t (getStatus_t) (struct SensorFusionGlobals *sfg);
145typedef void (updateStatus_t) (struct SensorFusionGlobals *sfg);
146typedef void (ssSetStatus_t) (struct StatusSubsystem *pStatus, fusion_status_t status);
147typedef fusion_status_t (ssGetStatus_t) (struct StatusSubsystem *pStatus);
148typedef void (ssUpdateStatus_t) (struct StatusSubsystem *pStatus);
149
164
165// Now start "standard" sensor fusion structure definitions
166
172{
173 uint8_t iWhoAmI;
175 int32_t iH;
176 int32_t iP;
177 float fH;
178 float fT;
181 int16_t iT;
182};
183
190{
191 uint8_t iWhoAmI;
193 uint8_t iFIFOCount;
194 uint16_t iFIFOExceeded;
196 // End of common fields which can be referenced via FifoSensor union type
197 float fGs[3];
198 float fGc[3];
201 int16_t iGs[3];
202 int16_t iGc[3];
203 int16_t iCountsPerg;
204};
205
212{
213 uint8_t iWhoAmI;
215 uint8_t iFIFOCount;
216 uint16_t iFIFOExceeded;
217 int16_t iBsFIFO[MAG_FIFO_SIZE][3];
218 // End of common fields which can be referenced via FifoSensor union type
219 float fBs[3];
220 float fBc[3];
223 int16_t iBs[3];
224 int16_t iBc[3];
225 int16_t iCountsPeruT;
226};
227
232{
233 float temperatureC; // temperature in Celsius
234};
235
242{
243 uint8_t iWhoAmI;
245 uint8_t iFIFOCount;
246 uint16_t iFIFOExceeded;
248 // End of common fields which can be referenced via FifoSensor union type
249 float fYs[3];
252 int16_t iYs[3];
253};
254
259 struct GyroSensor Gyro;
260 struct MagSensor Mag;
261 struct AccelSensor Accel;
262};
263
266{
267 float fLPH;
268 float fLPT;
269 float fdeltat;
270 float flpf;
271 int32_t systick;
272 int8_t resetflag;
273};
274
277{
278 // start: elements common to all motion state vectors
279 float fLPPhi;
280 float fLPThe;
281 float fLPPsi;
282 float fLPRho;
283 float fLPChi;
284 float fLPR[3][3];
286 float fLPRVec[3];
287 float fOmega[3];
288 int32_t systick;
289 // end: elements common to all motion state vectors
290 float fR[3][3];
292 float fdeltat;
293 float flpf;
294 int8_t resetflag;
295};
296
299{
300 // start: elements common to all motion state vectors
301 float fLPPhi;
302 float fLPThe;
303 float fLPPsi;
304 float fLPRho;
305 float fLPChi;
306 float fLPR[3][3];
308 float fLPRVec[3];
309 float fOmega[3];
310 int32_t systick;
311 // end: elements common to all motion state vectors
312 float fR[3][3];
314 float fdeltat;
315 float flpf;
316 int8_t resetflag;
317};
318
321{
322 // start: elements common to all motion state vectors
323 float fPhi;
324 float fThe;
325 float fPsi;
326 float fRho;
327 float fChi;
328 float fR[3][3];
330 float fRVec[3];
331 float fOmega[3];
332 int32_t systick;
333 // end: elements common to all motion state vectors
334 float fdeltat;
335 int8_t resetflag;
336};
337
340{
341 // start: elements common to all motion state vectors
342 float fLPPhi;
343 float fLPThe;
344 float fLPPsi;
345 float fLPRho;
346 float fLPChi;
347 float fLPR[3][3];
349 float fLPRVec[3];
350 float fOmega[3];
351 int32_t systick;
352 // end: elements common to all motion state vectors
353 float fR[3][3];
355 float fDelta;
356 float fLPDelta;
357 float fdeltat;
358 float flpf;
359 int8_t resetflag;
360};
361
364{
365 // start: elements common to all motion state vectors
366 float fPhiPl;
367 float fThePl;
368 float fPsiPl;
369 float fRhoPl;
370 float fChiPl;
371 float fRPl[3][3];
373 float fRVecPl[3];
374 float fOmega[3];
375 int32_t systick;
376 // end: elements common to all motion state vectors
377 float fQw6x6[6][6];
378 float fK6x3[6][3];
379 float fQwCT6x3[6][3];
380 float fQv;
381 float fZErr[3];
382 float fqgErrPl[3];
383 float fbPl[3];
384 float fbErrPl[3];
385 float fAccGl[3];
386 float fdeltat;
391 float fQwbOver3;
393 int8_t resetflag;
394};
395
398{
399 // start: elements common to all motion state vectors
400 float fPhiPl;
401 float fThePl;
402 float fPsiPl;
403 float fRhoPl;
404 float fChiPl;
405 float fRPl[3][3];
407 float fRVecPl[3];
408 float fOmega[3];
409 int32_t systick;
410 // end: elements common to all motion state vectors
411 float fQw9x9[9][9];
412 float fK9x6[9][6];
413 float fQwCT9x6[9][6];
414 float fZErr[6];
415 float fQv6x1[6];
416 float fDeltaPl;
419 float fqgErrPl[3];
420 float fqmErrPl[3];
421 float fbPl[3];
422 float fbErrPl[3];
423 float fAccGl[3];
424 float fVelGl[3];
425 float fDisGl[3];
426 float fdeltat;
427 float fgdeltat;
432 float fQwbOver3;
435 int8_t resetflag;
436};
437
440struct SV_COMMON {
441 float fPhi;
442 float fThe;
443 float fPsi;
444 float fRho;
445 float fChi;
446 float fRM[3][3];
448 float fRVec[3];
449 float fOmega[3];
450 int32_t systick;
451};
452
453typedef struct SV_COMMON *SV_ptr;
454
461{
462 // Subsystem Pointers
468 struct ControlSubsystem *pControlSubsystem;
469 struct StatusSubsystem *pStatusSubsystem;
473 uint32_t iFlags;
475 volatile uint8_t iPerturbation;
476 // Book-keeping variables
477 int32_t loopcounter;
478 int32_t systick_I2C;
486#if F_1DOF_P_BASIC
487 struct PressureSensor Pressure;
488#endif
489#if F_USING_ACCEL
490 struct AccelSensor Accel;
491 AccelCalibration AccelCal;
493#endif
494#if F_USING_MAG
495 struct MagSensor Mag;
498#endif
499#if F_USING_GYRO
500 struct GyroSensor Gyro;
501#endif
502 struct TempSensor Temp; //temperature storage
503
507#if F_1DOF_P_BASIC
509#endif
510#if F_3DOF_G_BASIC
512#endif
513#if F_3DOF_B_BASIC
515#endif
516#if F_3DOF_Y_BASIC
518#endif
519#if F_6DOF_GB_BASIC // 6DOF accel and mag eCompass: (accel + mag)
521#endif
522#if F_6DOF_GY_KALMAN
524#endif
525#if F_9DOF_GBY_KALMAN
527#endif
533 initializeFusionEngine_t *initializeFusionEngine ;
534 applyPerturbation_t *applyPerturbation ;
535 readSensors_t *readSensors;
536 runFusion_t *runFusion;
537 conditionSensorReadings_t *conditionSensorReadings;
538 clearFIFOs_t *clearFIFOs;
539 setStatus_t *setStatus;
540 setStatus_t *queueStatus;
541 updateStatus_t *updateStatus;
542 updateStatus_t *testStatus;
543 getStatus_t *getStatus;
544
547
548// The following functions are defined in sensor_fusion.c
551 struct StatusSubsystem *pStatusSubsystem,
552 struct ControlSubsystem *pControlSubsystem
553);
554installSensor_t installSensor;
555initializeFusionEngine_t initializeFusionEngine ;
563);
564void clearFIFOs(
566);
567runFusion_t runFusion;
568readSensors_t readSensors;
569void zeroArray(
570 struct StatusSubsystem *pStatus,
571 void* data,
572 uint16_t size,
573 uint16_t numElements,
574 uint8_t check
575);
583void conditionSample(
584 int16_t sample[3]
585);
586
594void addToFifo(
595 union FifoSensor *sensor,
596 uint16_t maxFifoSize,
597 int16_t sample[3]
598);
599
600// The following functions are defined in hal_axis_remap.c
601// Please note that these are board-dependent - they account for
602//various orientations of sensor ICs on the sensor PCB.
603
605void ApplyAccelHAL(
606 struct AccelSensor *Accel
607);
609void ApplyMagHAL(
610 struct MagSensor *Mag
611);
613void ApplyGyroHAL(
614 struct GyroSensor *Gyro
615);
623applyPerturbation_t ApplyPerturbation;
624
625#ifdef __cplusplus
626}
627#endif
628
629#endif // SENSOR_FUSION_H
Board configuration file.
#define GYRO_FIFO_SIZE
FXAX21000, FXAS21002 have 32 element FIFO.
Definition board.h:59
#define ACCEL_FIFO_SIZE
FXOS8700 (accel), MMA8652, FXLS8952 all have 32 element FIFO.
Definition board.h:60
#define MAG_FIFO_SIZE
FXOS8700 (mag) and MAG3110 have no FIFO so equivalent to 1 element FIFO. For.
Definition board.h:61
Build configuration file.
The driver_sensors_types.h file contains sensor state structs and error definitions.
Lower level magnetic calibration interface.
Matrix manipulation functions.
Functions to convert between various orientation representations.
Implements accelerometer calibration routines.
void zeroArray(struct StatusSubsystem *pStatus, void *data, uint16_t size, uint16_t numElements, uint8_t check)
void conditionSample(int16_t sample[3])
conditionSample ensures that we never encounter the maximum negative two's complement value for a 16-...
enum quaternion quaternion_type
the quaternion type to be transmitted
void initSensorFusionGlobals(SensorFusionGlobals *sfg, struct StatusSubsystem *pStatusSubsystem, struct ControlSubsystem *pControlSubsystem)
utility function to insert default values in the top level structure
quaternion
the quaternion type to be transmitted
@ Q6MA
Quaternion derived from 3-axis accel + 3 axis mag (eCompass)
@ Q3
Quaternion derived from 3-axis accel (tilt)
@ Q6AG
Quaternion derived from 3-axis accel + 3-axis gyro (gaming)
@ Q9
Quaternion derived from full 9-axis sensor fusion.
@ Q3M
Quaternion derived from 3-axis mag only (auto compass algorithm)
@ Q3G
Quaternion derived from 3-axis gyro only (rotation)
fusion_status_t
Application-specific serial communications system.
@ RECEIVING_WIRED
Receiving commands over wired interface (momentary)
@ HARD_FAULT
Non-recoverable FAULT = something went very wrong.
@ LOWPOWER
Running in reduced power mode.
@ NORMAL
Operation is Nominal.
@ RECEIVING_WIRELESS
Receiving commands over wireless interface (momentary)
@ INITIALIZING
Initializing sensors and algorithms.
@ OFF
These are the state definitions for the status subsystem.
@ SOFT_FAULT
Recoverable FAULT = something went wrong, but we can keep going.
void ApplyMagHAL(struct MagSensor *Mag)
Apply the magnetometer Hardware Abstraction Layer.
void clearFIFOs(SensorFusionGlobals *sfg)
Function to clear FIFO at the end of each fusion computation.
void ApplyGyroHAL(struct GyroSensor *Gyro)
Apply the gyroscope Hardware Abstraction Layer.
applyPerturbation_t ApplyPerturbation
ApplyPerturbation is a reverse unit-step test function.
int8_t() installSensor_t(struct SensorFusionGlobals *sfg, struct PhysicalSensor *sensor, uint16_t addr, uint16_t schedule, registerDeviceInfo_t *busInfo, initializeSensor_t *initialize, readSensor_t *read)
void addToFifo(union FifoSensor *sensor, uint16_t maxFifoSize, int16_t sample[3])
addToFifo is called from within sensor driver read functions
void conditionSensorReadings(SensorFusionGlobals *sfg)
void ApplyAccelHAL(struct AccelSensor *Accel)
Apply the accelerometer Hardware Abstraction Layer.
accelerometer measurement buffer
precision accelerometer calibration structure
The AccelSensor structure stores raw and processed measurements for a 3-axis accelerometer.
float fgPerCount
g per count
float fGc[3]
averaged precision calibrated measurement (g)
int16_t iCountsPerg
counts per g
bool isEnabled
true if the device is sampling
uint8_t iFIFOCount
number of measurements read from FIFO
float fCountsPerg
counts per g
uint16_t iFIFOExceeded
Number of samples received in excess of software FIFO size.
int16_t iGc[3]
averaged precision calibrated measurement (counts)
int16_t iGsFIFO[ACCEL_FIFO_SIZE][3]
FIFO measurements (counts)
int16_t iGs[3]
averaged measurement (counts)
float fGs[3]
averaged measurement (g)
uint8_t iWhoAmI
sensor whoami
The ControlSubsystem encapsulates command and data streaming functions.
Definition control.h:51
The GyroSensor structure stores raw and processed measurements for a 3-axis gyroscope.
uint8_t iWhoAmI
sensor whoami
int16_t iYs[3]
average measurement (counts)
int16_t iCountsPerDegPerSec
counts per deg/s
int16_t iYsFIFO[GYRO_FIFO_SIZE][3]
FIFO measurements (counts)
uint16_t iFIFOExceeded
Number of samples received in excess of software FIFO size.
uint8_t iFIFOCount
number of measurements read from FIFO
float fDegPerSecPerCount
deg/s per count
float fYs[3]
averaged measurement (deg/s)
bool isEnabled
true if the device is sampling
Magnetic Calibration Structure.
Definition magnetic.h:61
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor.
int16_t iBc[3]
averaged calibrated measurement (counts)
uint8_t iFIFOCount
number of measurements read from FIFO
float fCountsPeruT
counts per uT
float fuTPerCount
uT per count
float fBs[3]
averaged un-calibrated measurement (uT)
uint8_t iWhoAmI
sensor whoami
int16_t iBsFIFO[MAG_FIFO_SIZE][3]
FIFO measurements (counts)
uint16_t iFIFOExceeded
Number of samples received in excess of software FIFO size.
float fBc[3]
averaged calibrated measurement (uT)
bool isEnabled
true if the device is sampling
int16_t iBs[3]
averaged uncalibrated measurement (counts)
int16_t iCountsPeruT
counts per uT
An instance of PhysicalSensor structure type should be allocated for each physical sensors (combo dev...
registerDeviceInfo_t deviceInfo
I2C device context.
readSensor_t * read
pointer to function to read sensor using the supplied drivers
uint16_t addr
I2C address if applicable.
initializeSensor_t * initialize
pointer to function to initialize sensor using the supplied drivers
uint16_t isInitialized
Bitfields to indicate sensor is active (use SensorBitFields from build.h)
registerDeviceInfo_t * busInfo
information required for bus power management
struct PhysicalSensor * next
pointer to next sensor in this linked list
uint8_t schedule
Parameter to control sensor sampling rate.
The PressureSensor structure stores raw and processed measurements for an altimeter.
bool isEnabled
true if the device is sampling
int32_t iP
most recent unaveraged pressure (counts)
float fT
most recent unaveraged temperature (C)
uint8_t iWhoAmI
sensor whoami
float fmPerCount
meters per count
int32_t iH
most recent unaveraged height (counts)
float fCPerCount
degrees Celsius per count
int16_t iT
most recent unaveraged temperature (counts)
float fH
most recent unaveraged height (m)
quaternion structure definition
Definition orientation.h:25
The SV_1DOF_P_BASIC structure contains state information for a pressure sensor/altimeter.
float fdeltat
fusion time interval (s)
float flpf
low pass filter coefficient
int8_t resetflag
flag to request re-initialization on next pass
int32_t systick
systick timer
float fLPH
low pass filtered height (m)
float fLPT
low pass filtered temperature (C)
This is the 3DOF basic magnetometer state vector structure/.
float fLPChi
low pass tilt from vertical (deg)
int32_t systick
systick timer
Quaternion fq
unfiltered orientation quaternion
int8_t resetflag
flag to request re-initialization on next pass
float fLPPsi
low pass yaw (deg)
float fOmega[3]
angular velocity (deg/s)
float fR[3][3]
unfiltered orientation matrix
float flpf
low pass filter coefficient
Quaternion fLPq
low pass filtered orientation quaternion
float fdeltat
fusion time interval (s)
float fLPRVec[3]
rotation vector
float fLPThe
low pass pitch (deg)
float fLPRho
low pass compass (deg)
float fLPPhi
low pass roll (deg)
float fLPR[3][3]
low pass filtered orientation matrix
This is the 3DOF basic accelerometer state vector structure.
float fR[3][3]
unfiltered orientation matrix
Quaternion fq
unfiltered orientation quaternion
float fdeltat
fusion time interval (s)
float fLPThe
low pass pitch (deg)
float fLPPsi
low pass yaw (deg)
float fLPR[3][3]
low pass filtered orientation matrix
Quaternion fLPq
low pass filtered orientation quaternion
float fLPRho
low pass compass (deg)
int32_t systick
systick timer
float fLPRVec[3]
rotation vector
float flpf
low pass filter coefficient
float fLPChi
low pass tilt from vertical (deg)
int8_t resetflag
flag to request re-initialization on next pass
float fOmega[3]
angular velocity (deg/s)
float fLPPhi
low pass roll (deg)
SV_3DOF_Y_BASIC structure is the 3DOF basic gyroscope state vector structure.
float fRVec[3]
rotation vector
int32_t systick
systick timer
Quaternion fq
unfiltered orientation quaternion
float fOmega[3]
angular velocity (deg/s)
float fPhi
roll (deg)
float fPsi
yaw (deg)
float fR[3][3]
unfiltered orientation matrix
int8_t resetflag
flag to request re-initialization on next pass
float fThe
pitch (deg)
float fChi
tilt from vertical (deg)
float fRho
compass (deg)
float fdeltat
fusion filter sampling interval (s)
SV_6DOF_GB_BASIC is the 6DOF basic accelerometer and magnetometer state vector structure.
Quaternion fq
unfiltered orientation quaternion
float fLPPhi
low pass roll (deg)
Quaternion fLPq
low pass filtered orientation quaternion
float fLPR[3][3]
low pass filtered orientation matrix
int8_t resetflag
flag to request re-initialization on next pass
float fLPDelta
low pass filtered inclination angle (deg)
float fdeltat
fusion time interval (s)
float fR[3][3]
unfiltered orientation matrix
float fLPChi
low pass tilt from vertical (deg)
float flpf
low pass filter coefficient
float fDelta
unfiltered inclination angle (deg)
float fOmega[3]
virtual gyro angular velocity (deg/s)
float fLPPsi
low pass yaw (deg)
float fLPThe
low pass pitch (deg)
float fLPRho
low pass compass (deg)
float fLPRVec[3]
rotation vector
int32_t systick
systick timer
SV_6DOF_GY_KALMAN is the 6DOF Kalman filter accelerometer and gyroscope state vector structure.
float fQw6x6[6][6]
covariance matrix Qw
float fOmega[3]
average angular velocity (deg/s)
float fPsiPl
yaw (deg)
float fAccGl[3]
linear acceleration (g) in global frame
float fAlphaOver2
PI / 180 * fdeltat / 2.
float fqgErrPl[3]
gravity vector tilt orientation quaternion error (dimensionless)
float fbPl[3]
gyro offset (deg/s)
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
float fQwCT6x3[6][3]
Qw.C^T matrix.
float fRPl[3][3]
a posteriori orientation matrix
float fK6x3[6][3]
kalman filter gain matrix K
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
float fRhoPl
compass (deg)
float fThePl
pitch (deg)
Quaternion fqPl
a posteriori orientation quaternion
float fdeltat
sensor fusion interval (s)
float fChiPl
tilt from vertical (deg)
float fPhiPl
roll (deg)
float fQwbOver3
Qwb / 3.
float fZErr[3]
measurement error vector
int32_t systick
systick timer;
float fbErrPl[3]
gyro offset error (deg/s)
int8_t resetflag
flag to request re-initialization on next pass
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
float fQv
measurement noise covariance matrix leading diagonal
float fRVecPl[3]
rotation vector
SV_9DOF_GBY_KALMAN is the 9DOF Kalman filter accelerometer, magnetometer and gyroscope state vector s...
int32_t systick
systick timer;
float fPhiPl
roll (deg)
float fThePl
pitch (deg)
float fAlphaOver2
PI / 180 * fdeltat / 2.
float fChiPl
tilt from vertical (deg)
float fDeltaPl
a posteriori inclination angle from Kalman filter (deg)
float fqmErrPl[3]
geomagnetic vector tilt orientation quaternion error (dimensionless)
float fqgErrPl[3]
gravity vector tilt orientation quaternion error (dimensionless)
float fbErrPl[3]
gyro offset error (deg/s)
float fcosDeltaPl
cos(fDeltaPl)
float fsinDeltaPl
sin(fDeltaPl)
float fPsiPl
yaw (deg)
float fRhoPl
compass (deg)
float fK9x6[9][6]
kalman filter gain matrix K
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
float fQw9x9[9][9]
covariance matrix Qw
Quaternion fqPl
a posteriori orientation quaternion
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
float fRVecPl[3]
rotation vector
float fgdeltat
g (m/s2) * fdeltat
float fVelGl[3]
velocity (m/s) in global frame
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
float fDisGl[3]
displacement (m) in global frame
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
float fOmega[3]
average angular velocity (deg/s)
int8_t resetflag
flag to request re-initialization on next pass
float fAccGl[3]
linear acceleration (g) in global frame
float fbPl[3]
gyro offset (deg/s)
float fZErr[6]
measurement error vector
float fRPl[3][3]
a posteriori orientation matrix
float fdeltat
sensor fusion interval (s)
float fQwCT9x6[9][6]
Qw.C^T matrix.
float fQv6x1[6]
measurement noise covariance matrix leading diagonal
int8_t iFirstAccelMagLock
denotes that 9DOF orientation has locked to 6DOF eCompass
float fQwbOver3
Qwb / 3.
int32_t systick
systick timer;
float fChi
tilt from vertical (deg)
Quaternion fq
orientation quaternion
float fOmega[3]
average angular velocity (deg/s)
float fPhi
roll (deg)
float fThe
pitch (deg)
float fRho
compass (deg)
float fRVec[3]
rotation vector
float fRM[3][3]
orientation matrix
float fPsi
yaw (deg)
The top level fusion structure.
struct MagCalibration MagCal
mag cal storage
initializeFusionEngine_t * initializeFusionEngine
set sensor fusion structures to initial values
clearFIFOs_t * clearFIFOs
clear sensor FIFOs
installSensor_t * installSensor
function for installing a new sensor
struct PhysicalSensor * pSensors
a linked list of physical sensors
int32_t systick_I2C
systick counter to benchmark I2C reads
updateStatus_t * testStatus
increment to next enumerated status value (test only)
applyPerturbation_t * applyPerturbation
apply step function for testing purposes
setStatus_t * queueStatus
queue status change for next regular interval
conditionSensorReadings_t * conditionSensorReadings
preprocessing step for sensor fusion
getStatus_t * getStatus
fetch the current status from the Status Subsystem
struct MagSensor Mag
magnetometer storage
int32_t systick_Spare
systick counter for counts spare waiting for timing interrupt
int32_t loopcounter
counter incrementing each iteration of sensor fusion (typically 25Hz)
runFusion_t * runFusion
run the fusion routines
volatile uint8_t iPerturbation
test perturbation to be applied
readSensors_t * readSensors
read all physical sensors
setStatus_t * setStatus
change status indicator immediately
updateStatus_t * updateStatus
status=next status
uint32_t iFlags
a bit-field of sensors and algorithms used
StatusSubsystem() provides an object-like interface for communicating status to the user.
Definition status.h:26
fusion_status_t status
Current status.
Definition status.h:29
The TempSensor structure stores raw temperature readings.
This structure defines the device specific info required by register I/O.
The FifoSensor union allows us to use common pointers for Accel, Mag & Gyro logical sensor structures...