ISSDK  1.7
IoT Sensing Software Development Kit
fusion.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 
36 /*! \file fusion.h
37  \brief Lower level sensor fusion interface
38 
39  This file can be used to "tune" the performance of specific algorithms
40  within the sensor fusion library. It also defines the lower level function
41  definitions for specific algorithms. Normally, the higher level hooks
42  in sensor_fusion.h will be used, and those shown here will be left alone.
43 */
44 
45 #ifndef FUSION_H
46 #define FUSION_H
47 
48 #include "sensor_fusion.h"
49 
50 /// @name COMPUTE_1DOF_P_BASIC constants
51 ///@{
52 #define FLPFSECS_1DOF_P_BASIC 1.5F ///< pressure low pass filter time constant (s)
53 ///@}
54 
55 /// @name COMPUTE_3DOF_G_BASIC constants
56 ///@{
57 #define FLPFSECS_3DOF_G_BASIC 1.0F ///< tilt orientation low pass filter time constant (s)
58 ///@}
59 
60 /// @name COMPUTE_3DOF_B_BASIC constants
61 ///@{
62 #define FLPFSECS_3DOF_B_BASIC 7.0F ///< 2D eCompass orientation low pass filter time constant (s)
63 ///@}
64 
65 /// @name COMPUTE_6DOF_GB_BASIC constants
66 ///@{
67 #define FLPFSECS_6DOF_GB_BASIC 7.0F /// <3D eCompass orientation low pass filter time constant (s)
68 ///@}
69 
70 /// @name COMPUTE_6DOF_GY_KALMAN constants
71 ///@{
72 #define FQVY_6DOF_GY_KALMAN 2E2 ///< gyro sensor noise variance units (deg/s)^2
73 #define FQVG_6DOF_GY_KALMAN 1.2E-3 ///< accelerometer sensor noise variance units g^2
74 #define FQWB_6DOF_GY_KALMAN 2E-2F ///< gyro offset random walk units (deg/s)^2
75 #define FMIN_6DOF_GY_BPL -7.0F ///< minimum permissible power on gyro offsets (deg/s)
76 #define FMAX_6DOF_GY_BPL 7.0F ///< maximum permissible power on gyro offsets (deg/s)
77 ///@}
78 
79 /// @name COMPUTE_9DOF_GBY_KALMAN constants
80 ///@{
81 /// gyro sensor noise covariance units deg^2
82 /// increasing this parameter improves convergence to the geomagnetic field
83 #define FQVY_9DOF_GBY_KALMAN 2E2 ///< gyro sensor noise variance units (deg/s)^2
84 #define FQVG_9DOF_GBY_KALMAN 1.2E-3 ///< accelerometer sensor noise variance units g^2 defining minimum deviation from 1g sphere
85 #define FQVB_9DOF_GBY_KALMAN 5E0 ///< magnetometer sensor noise variance units uT^2 defining minimum deviation from geomagnetic sphere.
86 #define FQWB_9DOF_GBY_KALMAN 2E-2F ///< gyro offset random walk units (deg/s)^2
87 #define FMIN_9DOF_GBY_BPL -7.0F ///< minimum permissible power on gyro offsets (deg/s)
88 #define FMAX_9DOF_GBY_BPL 7.0F ///< maximum permissible power on gyro offsets (deg/s)
89 ///@}
90 
91 /// @name Fusion Function Prototypes
92 /// These functions comprise the core of the basic sensor fusion functions excluding
93 /// magnetic and acceleration calibration. Parameter descriptions are not included here,
94 /// as details are provided in sensor_fusion.h.
95 ///@{
97 void fFuseSensors(struct SV_1DOF_P_BASIC *pthisSV_1DOF_P_BASIC, struct SV_3DOF_G_BASIC *pthisSV_3DOF_G_BASIC,
98  struct SV_3DOF_B_BASIC *pthisSV_3DOF_B_BASIC, struct SV_3DOF_Y_BASIC *pthisSV_3DOF_Y_BASIC,
99  struct SV_6DOF_GB_BASIC *pthisSV_6DOF_GB_BASIC, struct SV_6DOF_GY_KALMAN *pthisSV_6DOF_GY_KALMAN,
100  struct SV_9DOF_GBY_KALMAN *pthisSV_9DOF_GBY_KALMAN,
101  struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro,
102  struct PressureSensor *pthisPressure, struct MagCalibration *pthisMagCal);
103 void fInit_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure, float flpftimesecs);
104 void fInit_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel, float flpftimesecs);
105 void fInit_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag, float flpftimesecs);
106 void fInit_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV);
107 void fInit_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, float flpftimesecs);
108 void fInit_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro);
109 void fInit_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag,
110  struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal);
111 void fRun_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure);
112 void fRun_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel);
113 void fRun_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag);
114 void fRun_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV, struct GyroSensor *pthisGyro);
115 void fRun_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct MagSensor *pthisMag, struct AccelSensor *pthisAccel);
116 void fRun_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro);
117 void fRun_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal);
118 ///@}
119 
120 #endif // #ifndef FUSION_H
SensorFusionGlobals sfg
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_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct MagSensor *pthisMag, struct AccelSensor *pthisAccel)
Definition: fusion.c:608
void fRun_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure)
Definition: fusion.c:445
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:372
void fInit_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel, float flpftimesecs)
Definition: fusion.c:205
This is the 3DOF basic magnetometer state vector structure/.
The AccelSensor structure stores raw and processed measurements for a 3-axis accelerometer.
SV_9DOF_GBY_KALMAN is the 9DOF Kalman filter accelerometer, magnetometer and gyroscope state vector s...
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor...
The top level fusion structure.
void fRun_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
Definition: fusion.c:661
The SV_1DOF_P_BASIC structure contains state information for a pressure sensor/altimeter.
SV_6DOF_GY_KALMAN is the 6DOF Kalman filter accelerometer and gyroscope state vector structure...
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:94
void fInit_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV)
Definition: fusion.c:261
void fRun_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag)
Definition: fusion.c:515
void fInit_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, float flpftimesecs)
Definition: fusion.c:276
The sensor_fusion.h file implements the top level programming interface.
SV_3DOF_Y_BASIC structure is the 3DOF basic gyroscope state vector structure.
void fInit_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure, float flpftimesecs)
Definition: fusion.c:180
void fInit_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
Definition: fusion.c:308
Magnetic Calibration Structure.
Definition: magnetic.h:81
void fInitializeFusion(SensorFusionGlobals *sfg)
Definition: fusion.c:59
void fRun_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV, struct GyroSensor *pthisGyro)
Definition: fusion.c:560
SV_6DOF_GB_BASIC is the 6DOF basic accelerometer and magnetometer state vector structure.
void fInit_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag, float flpftimesecs)
Definition: fusion.c:233
This is the 3DOF basic accelerometer state vector structure.
The GyroSensor structure stores raw and processed measurements for a 3-axis gyroscope.
void fRun_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel)
Definition: fusion.c:465
The PressureSensor structure stores raw and processed measurements for an altimeter.