ISSDK  1.8
IoT Sensing Software Development Kit
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 
10 /*! \file fusion.h
11  \brief Lower level sensor fusion interface
12 
13  This file can be used to "tune" the performance of specific algorithms
14  within the sensor fusion library. It also defines the lower level function
15  definitions for specific algorithms. Normally, the higher level hooks
16  in sensor_fusion.h will be used, and those shown here will be left alone.
17 */
18 
19 #ifndef FUSION_H
20 #define FUSION_H
21 
22 #include "sensor_fusion.h"
23 
24 /// @name COMPUTE_1DOF_P_BASIC constants
25 ///@{
26 #define FLPFSECS_1DOF_P_BASIC 1.5F ///< pressure low pass filter time constant (s)
27 ///@}
28 
29 /// @name COMPUTE_3DOF_G_BASIC constants
30 ///@{
31 #define FLPFSECS_3DOF_G_BASIC 1.0F ///< tilt orientation low pass filter time constant (s)
32 ///@}
33 
34 /// @name COMPUTE_3DOF_B_BASIC constants
35 ///@{
36 #define FLPFSECS_3DOF_B_BASIC 7.0F ///< 2D eCompass orientation low pass filter time constant (s)
37 ///@}
38 
39 /// @name COMPUTE_6DOF_GB_BASIC constants
40 ///@{
41 #define FLPFSECS_6DOF_GB_BASIC 7.0F /// <3D eCompass orientation low pass filter time constant (s)
42 ///@}
43 
44 /// @name COMPUTE_6DOF_GY_KALMAN constants
45 ///@{
46 #define FQVY_6DOF_GY_KALMAN 2E2 ///< gyro sensor noise variance units (deg/s)^2
47 #define FQVG_6DOF_GY_KALMAN 1.2E-3 ///< accelerometer sensor noise variance units g^2
48 #define FQWB_6DOF_GY_KALMAN 2E-2F ///< gyro offset random walk units (deg/s)^2
49 #define FMIN_6DOF_GY_BPL -7.0F ///< minimum permissible power on gyro offsets (deg/s)
50 #define FMAX_6DOF_GY_BPL 7.0F ///< maximum permissible power on gyro offsets (deg/s)
51 ///@}
52 
53 /// @name COMPUTE_9DOF_GBY_KALMAN constants
54 ///@{
55 /// gyro sensor noise covariance units deg^2
56 /// increasing this parameter improves convergence to the geomagnetic field
57 #define FQVY_9DOF_GBY_KALMAN 2E2 ///< gyro sensor noise variance units (deg/s)^2
58 #define FQVG_9DOF_GBY_KALMAN 1.2E-3 ///< accelerometer sensor noise variance units g^2 defining minimum deviation from 1g sphere
59 #define FQVB_9DOF_GBY_KALMAN 5E0 ///< magnetometer sensor noise variance units uT^2 defining minimum deviation from geomagnetic sphere.
60 #define FQWB_9DOF_GBY_KALMAN 2E-2F ///< gyro offset random walk units (deg/s)^2
61 #define FMIN_9DOF_GBY_BPL -7.0F ///< minimum permissible power on gyro offsets (deg/s)
62 #define FMAX_9DOF_GBY_BPL 7.0F ///< maximum permissible power on gyro offsets (deg/s)
63 ///@}
64 
65 /// @name Fusion Function Prototypes
66 /// These functions comprise the core of the basic sensor fusion functions excluding
67 /// magnetic and acceleration calibration. Parameter descriptions are not included here,
68 /// as details are provided in sensor_fusion.h.
69 ///@{
71 void fFuseSensors(struct SV_1DOF_P_BASIC *pthisSV_1DOF_P_BASIC, struct SV_3DOF_G_BASIC *pthisSV_3DOF_G_BASIC,
72  struct SV_3DOF_B_BASIC *pthisSV_3DOF_B_BASIC, struct SV_3DOF_Y_BASIC *pthisSV_3DOF_Y_BASIC,
73  struct SV_6DOF_GB_BASIC *pthisSV_6DOF_GB_BASIC, struct SV_6DOF_GY_KALMAN *pthisSV_6DOF_GY_KALMAN,
74  struct SV_9DOF_GBY_KALMAN *pthisSV_9DOF_GBY_KALMAN,
75  struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro,
76  struct PressureSensor *pthisPressure, struct MagCalibration *pthisMagCal);
77 void fInit_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure, float flpftimesecs);
78 void fInit_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel, float flpftimesecs);
79 void fInit_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag, float flpftimesecs);
80 void fInit_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV);
81 void fInit_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, float flpftimesecs);
82 void fInit_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro);
83 void fInit_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag,
84  struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal);
85 void fRun_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure);
86 void fRun_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel);
87 void fRun_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag);
88 void fRun_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV, struct GyroSensor *pthisGyro);
89 void fRun_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct MagSensor *pthisMag, struct AccelSensor *pthisAccel);
90 void fRun_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro);
91 void fRun_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal);
92 ///@}
93 
94 #endif // #ifndef FUSION_H
This is the 3DOF basic accelerometer state vector structure.
The GyroSensor structure stores raw and processed measurements for a 3-axis gyroscope.
void fRun_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal)
void fRun_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
Definition: fusion.c:635
SV_9DOF_GBY_KALMAN is the 9DOF Kalman filter accelerometer, magnetometer and gyroscope state vector s...
SV_3DOF_Y_BASIC structure is the 3DOF basic gyroscope state vector structure.
The SV_1DOF_P_BASIC structure contains state information for a pressure sensor/altimeter.
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor...
void fInit_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV)
Definition: fusion.c:235
void fRun_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV, struct GyroSensor *pthisGyro)
Definition: fusion.c:534
The top level fusion structure.
void fInit_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag, float flpftimesecs)
Definition: fusion.c:207
SV_6DOF_GY_KALMAN is the 6DOF Kalman filter accelerometer and gyroscope state vector structure...
This is the 3DOF basic magnetometer state vector structure/.
void fInitializeFusion(SensorFusionGlobals *sfg)
Definition: fusion.c:33
The AccelSensor structure stores raw and processed measurements for a 3-axis accelerometer.
void fRun_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel)
Definition: fusion.c:439
The sensor_fusion.h file implements the top level programming interface.
Magnetic Calibration Structure.
Definition: magnetic.h:55
void fInit_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel, float flpftimesecs)
Definition: fusion.c:179
void fFuseSensors(struct SV_1DOF_P_BASIC *pthisSV_1DOF_P_BASIC, struct SV_3DOF_G_BASIC *pthisSV_3DOF_G_BASIC, struct SV_3DOF_B_BASIC *pthisSV_3DOF_B_BASIC, struct SV_3DOF_Y_BASIC *pthisSV_3DOF_Y_BASIC, struct SV_6DOF_GB_BASIC *pthisSV_6DOF_GB_BASIC, struct SV_6DOF_GY_KALMAN *pthisSV_6DOF_GY_KALMAN, struct SV_9DOF_GBY_KALMAN *pthisSV_9DOF_GBY_KALMAN, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct PressureSensor *pthisPressure, struct MagCalibration *pthisMagCal)
Definition: fusion.c:68
The PressureSensor structure stores raw and processed measurements for an altimeter.
void fRun_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag)
Definition: fusion.c:489
SensorFusionGlobals sfg
void fInit_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, float flpftimesecs)
Definition: fusion.c:250
void fRun_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct MagSensor *pthisMag, struct AccelSensor *pthisAccel)
Definition: fusion.c:582
void fInit_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal)
Definition: fusion.c:346
void fRun_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure)
Definition: fusion.c:419
void fInit_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
Definition: fusion.c:282
SV_6DOF_GB_BASIC is the 6DOF basic accelerometer and magnetometer state vector structure.
void fInit_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure, float flpftimesecs)
Definition: fusion.c:154