42 sfg->SV_1DOF_P_BASIC.resetflag =
true;
45 sfg->SV_3DOF_B_BASIC.resetflag =
true;
48 sfg->SV_3DOF_G_BASIC.resetflag =
true;
51 sfg->SV_3DOF_Y_BASIC.resetflag =
true;
54 sfg->SV_6DOF_GB_BASIC.resetflag =
true;
57 sfg->SV_6DOF_GY_KALMAN.resetflag =
true;
60 sfg->SV_9DOF_GBY_KALMAN.resetflag =
true;
83 if (pthisSV_1DOF_P_BASIC)
93 if (pthisSV_3DOF_G_BASIC)
103 if (pthisSV_3DOF_B_BASIC)
113 if (pthisSV_3DOF_Y_BASIC)
123 if (pthisSV_6DOF_GB_BASIC)
133 if (pthisSV_6DOF_GY_KALMAN)
142 #if F_9DOF_GBY_KALMAN 143 if (pthisSV_9DOF_GBY_KALMAN)
147 pthisGyro, pthisMagCal);
164 if (flpftimesecs > pthisSV->
fdeltat)
167 pthisSV->
flpf = 1.0F;
170 pthisSV->
fLPH = pthisPressure->
fH;
171 pthisSV->
fLPT = pthisPressure->
fT;
180 struct AccelSensor *pthisAccel,
float flpftimesecs)
186 if (flpftimesecs > pthisSV->
fdeltat)
189 pthisSV->
flpf = 1.0F;
192 #if THISCOORDSYSTEM == NED 194 #elif THISCOORDSYSTEM == ANDROID 208 struct MagSensor *pthisMag,
float flpftimesecs)
214 if (flpftimesecs > pthisSV->
fdeltat)
217 pthisSV->
flpf = 1.0F;
220 #if THISCOORDSYSTEM == NED 222 #elif THISCOORDSYSTEM == ANDROID 252 struct MagSensor *pthisMag,
float flpftimesecs)
260 if (flpftimesecs > pthisSV->
fdeltat)
263 pthisSV->
flpf = 1.0F;
266 #if THISCOORDSYSTEM == NED 268 #elif THISCOORDSYSTEM == ANDROID 299 for (i =
CHX; i <=
CHZ; i++)
309 if (*((
uint32 *) pFlash++) == 0x12345678)
312 for (i =
CHX; i <=
CHZ; i++) pthisSV->
fbPl[i] = *(pFlash++);
318 for (i =
CHX; i <=
CHZ; i++)
322 pthisSV->
fbPl[i] = pthisGyro->
fYs[i];
324 pthisSV->
fbPl[i] = 0.0F;
330 #if THISCOORDSYSTEM == NED 332 #elif THISCOORDSYSTEM == ANDROID 364 for (i =
CHX; i <=
CHZ; i++) {
368 pthisSV->
fVelGl[i] = 0.0F;
369 pthisSV->
fDisGl[i] = 0.0F;
376 if (*((
uint32*) pFlash++) == 0x12345678) {
378 for (i =
CHX; i <=
CHZ; i++)
379 pthisSV->
fbPl[i] = *(pFlash++);
383 for (i =
CHX; i <=
CHZ; i++) {
385 pthisSV->
fbPl[i] = pthisGyro->
fYs[i];
387 pthisSV->
fbPl[i] = 0.0F;
395 #if THISCOORDSYSTEM == NED 397 pthisMag->
fBc, pthisAccel->
fGc, &ftmp, &ftmp);
398 #elif THISCOORDSYSTEM == ANDROID 400 pthisMag->
fBc, pthisAccel->
fGc, &ftmp, &ftmp);
403 pthisMag->
fBc, pthisAccel->
fGc, &ftmp, &ftmp);
432 pthisSV->
fLPH += pthisSV->
flpf * (pthisPressure->
fH - pthisSV->
fLPH);
433 pthisSV->
fLPT += pthisSV->
flpf * (pthisPressure->
fT - pthisSV->
fLPT);
450 #if THISCOORDSYSTEM == NED 452 #elif THISCOORDSYSTEM == ANDROID 468 #if THISCOORDSYSTEM == NED 472 #elif THISCOORDSYSTEM == ANDROID 499 #if THISCOORDSYSTEM == NED 501 #elif THISCOORDSYSTEM == ANDROID 517 #if THISCOORDSYSTEM == NED 521 #elif THISCOORDSYSTEM == ANDROID 565 #if THISCOORDSYSTEM == NED 568 &(pthisSV->
fRho), &(pthisSV->
fChi));
569 #elif THISCOORDSYSTEM == ANDROID 572 &(pthisSV->
fRho), &(pthisSV->
fChi));
576 &(pthisSV->
fRho), &(pthisSV->
fChi));
585 float ftmp1, ftmp2, ftmp3, ftmp4;
596 #if THISCOORDSYSTEM == NED 598 #elif THISCOORDSYSTEM == ANDROID 614 #if THISCOORDSYSTEM == NED 618 #elif THISCOORDSYSTEM == ANDROID 641 float ftmp3DOF3x1[3];
642 float ftmpA3x3[3][3];
669 for (i =
CHX; i <=
CHZ; i++)
670 pthisSV->
fOmega[i] = (
float) pthisGyro->
iYs[i] *
676 fqMi = pthisSV->
fqPl;
686 for (i =
CHX; i <=
CHZ; i++)
687 ftmpMi3x1[i] = (
float) pthisGyro->
iYsFIFO[j][i] *
706 fmodGc = sqrtf(fabs(pthisAccel->
fGc[
CHX] * pthisAccel->
fGc[
CHX] +
712 ftmp = 1.0F / fmodGc;
713 ftmp3DOF3x1[
CHX] = pthisAccel->
fGc[
CHX] * ftmp;
714 ftmp3DOF3x1[
CHY] = pthisAccel->
fGc[
CHY] * ftmp;
715 ftmp3DOF3x1[
CHZ] = pthisAccel->
fGc[
CHZ] * ftmp;
720 ftmp3DOF3x1[
CHX] = 0.0F;
721 ftmp3DOF3x1[
CHY] = 0.0F;
722 ftmp3DOF3x1[
CHZ] = 1.0F;
726 #if THISCOORDSYSTEM == NED 728 #elif THISCOORDSYSTEM == ANDROID 730 ftmp3DOF3x1[
CHX] = -ftmp3DOF3x1[
CHX];
731 ftmp3DOF3x1[
CHY] = -ftmp3DOF3x1[
CHY];
732 ftmp3DOF3x1[
CHZ] = -ftmp3DOF3x1[
CHZ];
738 ftmpMi3x1[
CHX] = 2.0F * (fqMi.
q1 * fqMi.
q3 - fqMi.
q0 * fqMi.
q2);
739 ftmpMi3x1[
CHY] = 2.0F * (fqMi.
q2 * fqMi.
q3 + fqMi.
q0 * fqMi.
q1);
740 ftmpMi3x1[
CHZ] = 2.0F * (fqMi.
q0 * fqMi.
q0 + fqMi.
q3 * fqMi.
q3) - 1.0F;
743 #if THISCOORDSYSTEM == NED 745 #else // ANDROID and WIN8 747 ftmpMi3x1[
CHX] = -ftmpMi3x1[
CHX];
748 ftmpMi3x1[
CHY] = -ftmpMi3x1[
CHY];
749 ftmpMi3x1[
CHZ] = -ftmpMi3x1[
CHZ];
763 for (i = 0; i < 6; i++)
764 for (j = 0; j < 6; j++) pthisSV->
fQw6x6[i][j] = 0.0F;
808 ftmp = fmodGc - 1.0F;
809 fQvGQa = 3.0F * ftmp * ftmp;
815 for (i = 0; i < 6; i++)
817 for (j = 0; j < 3; j++)
822 for (k = 0; k < 6; k++)
826 if (k == j) fC3x6jk = 1.0F;
830 if ((pthisSV->
fQw6x6[i][k] != 0.0F) && (fC3x6jk != 0.0F))
842 for (i = 0; i < 3; i++)
844 for (j = i; j < 3; j++)
848 ftmpA3x3[i][j] = pthisSV->
fQv;
850 ftmpA3x3[i][j] = 0.0F;
853 for (k = 0; k < 6; k++)
857 if (k == i) fC3x6ik = 1.0F;
861 if ((fC3x6ik != 0.0F) && (pthisSV->
fQwCT6x3[k][j] != 0.0F))
864 ftmpA3x3[i][j] += pthisSV->
fQwCT6x3[k][j];
866 ftmpA3x3[i][j] += fC3x6ik * pthisSV->
fQwCT6x3[k][j];
873 ftmpA3x3[1][0] = ftmpA3x3[0][1];
874 ftmpA3x3[2][0] = ftmpA3x3[0][2];
875 ftmpA3x3[2][1] = ftmpA3x3[1][2];
878 for (i = 0; i < 3; i++) pfRows[i] = ftmpA3x3[i];
885 for (i = 0; i < 6; i++)
887 for (j = 0; j < 3; j++)
889 pthisSV->
fK6x3[i][j] = 0.0F;
890 for (k = 0; k < 3; k++)
892 if ((pthisSV->
fQwCT6x3[i][k] != 0.0F) &&
893 (ftmpA3x3[k][j] != 0.0F))
895 pthisSV->
fK6x3[i][j] += pthisSV->
fQwCT6x3[i][k] * ftmpA3x3[k][j];
904 for (i = 0; i < 6; i++)
906 for (j = 0; j < 3; j++)
908 pthisSV->
fK6x3[i][j] = 0.0F;
915 for (i =
CHX; i <=
CHZ; i++)
924 if (pthisSV->
fK6x3[i][CHZ] != 0.0F)
928 if (pthisSV->
fK6x3[i + 3][
CHX] != 0.0F)
932 if (pthisSV->
fK6x3[i + 3][
CHY] != 0.0F)
934 if (pthisSV->
fK6x3[i + 3][CHZ] != 0.0F)
942 ftmp = ftmpq.
q1 * ftmpq.
q1 + ftmpq.
q2 * ftmpq.
q2 + ftmpq.
q3 * ftmpq.
q3;
948 ftmpq.
q0 = sqrtf(fabsf(1.0F - ftmp));
953 ftmp = 1.0F / sqrtf(ftmp);
970 for (i =
CHX; i <=
CHZ; i++)
986 #if THISCOORDSYSTEM == NED 991 #elif THISCOORDSYSTEM == ANDROID 1002 #if THISCOORDSYSTEM == NED 1006 #elif THISCOORDSYSTEM == ANDROID 1017 #if F_9DOF_GBY_KALMAN 1026 float ftmpA6x6[6][6];
1033 float ftmpA3x3[3][3];
1043 float fsinDelta6DOF;
1044 float fcosDelta6DOF;
1070 fqMi = pthisSV->
fqPl;
1076 for (j = 0; j < pthisGyro->
iFIFOCount; j++) {
1095 #if THISCOORDSYSTEM == NED 1096 feCompassNED(fR6DOF, &fDelta6DOF, &fsinDelta6DOF, &fcosDelta6DOF, pthisMag->
fBc, pthisAccel->
fGc, &fmodBc, &fmodGc);
1097 #elif THISCOORDSYSTEM == ANDROID 1098 feCompassAndroid(fR6DOF, &fDelta6DOF, &fsinDelta6DOF, &fcosDelta6DOF, pthisMag->
fBc, pthisAccel->
fGc, &fmodBc, &fmodGc);
1100 feCompassWin8(fR6DOF, &fDelta6DOF, &fsinDelta6DOF, &fcosDelta6DOF, pthisMag->
fBc, pthisAccel->
fGc, &fmodBc, &fmodGc);
1107 ftmp = fmodGc - 1.0F;
1108 fQvGQa = 3.0F * ftmp * ftmp;
1113 ftmp = fmodBc - pthisMagCal->
fB;
1114 fQvBQd = 3.0F * ftmp * ftmp;
1122 fqMi = pthisSV->
fqPl = fq6DOF;
1132 #if THISCOORDSYSTEM == NED 1139 #else // ANDROID and WIN8 (ENU gravity positive) 1157 #if THISCOORDSYSTEM == NED 1158 ftmpA3x1[
CHX] = fR6DOF[
CHX][
CHX] * fcosDelta6DOF + fR6DOF[
CHX][
CHZ] * fsinDelta6DOF;
1159 ftmpA3x1[
CHY] = fR6DOF[
CHY][
CHX] * fcosDelta6DOF + fR6DOF[
CHY][
CHZ] * fsinDelta6DOF;
1160 ftmpA3x1[
CHZ] = fR6DOF[
CHZ][
CHX] * fcosDelta6DOF + fR6DOF[
CHZ][
CHZ] * fsinDelta6DOF;
1164 #else // ANDROID and WIN8 (both ENU coordinate systems) 1165 ftmpA3x1[
CHX] = fR6DOF[
CHX][
CHY] * fcosDelta6DOF - fR6DOF[
CHX][
CHZ] * fsinDelta6DOF;
1166 ftmpA3x1[
CHY] = fR6DOF[
CHY][
CHY] * fcosDelta6DOF - fR6DOF[
CHY][
CHZ] * fsinDelta6DOF;
1167 ftmpA3x1[
CHZ] = fR6DOF[
CHZ][
CHY] * fcosDelta6DOF - fR6DOF[
CHZ][
CHZ] * fsinDelta6DOF;
1184 for (i = 0; i < 9; i++)
1185 for (j = i; j < 9; j++)
1186 pthisSV->
fQw9x9[i][j] = 0.0F;
1220 for (i = 1; i < 9; i++)
1221 for (j = 0; j < i; j++)
1230 for (i = 0; i < 9; i++) {
1231 for (j = 0; j < 6; j++) {
1234 for (k = 0; k < 9; k++) {
1239 if (k == j) fC6x9jk = 1.0F;
1240 if (k == (j + 6)) fC6x9jk = -pthisSV->
fAlphaOver2;
1243 if (k == j) fC6x9jk = 1.0F;
1244 if (k == (j + 3)) fC6x9jk = -pthisSV->
fAlphaOver2;
1248 if ((pthisSV->
fQw9x9[i][k] != 0.0F) && (fC6x9jk != 0.0F)) {
1249 if (fC6x9jk == 1.0F) pthisSV->
fQwCT9x6[i][j] += pthisSV->
fQw9x9[i][k];
1257 for (i = 0; i < 6; i++) {
1258 for (j = i; j < 6; j++) {
1260 if (i == j) ftmpA6x6[i][j] = pthisSV->
fQv6x1[i];
1261 else ftmpA6x6[i][j] = 0.0F;
1263 for (k = 0; k < 9; k++) {
1268 if (k == i) fC6x9ik = 1.0F;
1269 if (k == (i + 6)) fC6x9ik = -pthisSV->
fAlphaOver2;
1272 if (k == i) fC6x9ik = 1.0F;
1273 if (k == (i + 3)) fC6x9ik = -pthisSV->
fAlphaOver2;
1277 if ((fC6x9ik != 0.0F) && (pthisSV->
fQwCT9x6[k][j] != 0.0F)) {
1278 if (fC6x9ik == 1.0F) ftmpA6x6[i][j] += pthisSV->
fQwCT9x6[k][j];
1279 else ftmpA6x6[i][j] += fC6x9ik * pthisSV->
fQwCT9x6[k][j];
1285 for (i = 1; i < 6; i++)
1286 for (j = 0; j < i; j++)
1287 ftmpA6x6[i][j] = ftmpA6x6[j][i];
1290 for (i = 0; i < 6; i++)
1291 pfRows[i] = ftmpA6x6[i];
1297 for (i = 0; i < 9; i++)
1298 for (j = 0; j < 6; j++) {
1299 pthisSV->
fK9x6[i][j] = 0.0F;
1300 for (k = 0; k < 6; k++) {
1301 if ((pthisSV->
fQwCT9x6[i][k] != 0.0F) && (ftmpA6x6[k][j] != 0.0F))
1302 pthisSV->
fK9x6[i][j] += pthisSV->
fQwCT9x6[i][k] * ftmpA6x6[k][j];
1307 for (i = 0; i < 9; i++)
1308 for (j = 0; j < 6; j++)
1309 pthisSV->
fK9x6[i][j] = 0.0F;
1314 for (i =
CHX; i <=
CHZ; i++) {
1316 for (j = 0; j < 6; j++) {
1318 if (pthisSV->
fK9x6[i][j] != 0.0F)
1322 if (pthisSV->
fK9x6[i + 3][j] != 0.0F)
1326 if (pthisSV->
fK9x6[i + 6][j] != 0.0F)
1335 ftmpq.
q0 = sqrtf(fabs(1.0F - ftmpq.
q1 * ftmpq.
q1 - ftmpq.
q2 * ftmpq.
q2 - ftmpq.
q3 * ftmpq.
q3));
1340 fveqRu(fgPl, ftmpA3x3, fgMi, 0);
1346 ftmpq.
q0 = sqrtf(fabs(1.0F - ftmpq.
q1 * ftmpq.
q1 - ftmpq.
q2 * ftmpq.
q2 - ftmpq.
q3 * ftmpq.
q3));
1351 fveqRu(fmPl, ftmpA3x3, fmMi, 0);
1355 #if THISCOORDSYSTEM == NED// gravity vector is +z and accel measurement is +z when flat so don't negate 1357 fmPl, fgPl, &fmodBc, &fmodGc);
1358 #elif THISCOORDSYSTEM == ANDROID // gravity vector is -z and accel measurement is +z when flat so negate 1359 ftmpA3x1[
CHX] = -fgPl[
CHX];
1360 ftmpA3x1[
CHY] = -fgPl[
CHY];
1361 ftmpA3x1[
CHZ] = -fgPl[
CHZ];
1363 fmPl, ftmpA3x1, &fmodBc, &fmodGc);
1364 #else // WIN8// gravity vector is -z and accel measurement is -1g when flat so don't negate 1366 fmPl, fgPl, &fmodBc, &fmodGc);
1374 for (i =
CHX; i <=
CHZ; i++) {
1393 #if THISCOORDSYSTEM == NED 1398 #elif THISCOORDSYSTEM == ANDROID 1411 for (i =
CHX; i <=
CHZ; i++) {
1419 #if THISCOORDSYSTEM == NED 1421 #elif THISCOORDSYSTEM == ANDROID 1429 #endif // #if F_9DOF_GBY_KALMAN float fK6x3[6][3]
kalman filter gain matrix K
float q2
y vector component
void f3DOFMagnetometerMatrixWin8(float fR[][3], float fBc[])
Windows 8 magnetometer 3DOF flat eCompass function, computing rotation matrix fR. ...
int32_t systick
systick timer;
Quaternion fLPq
low pass filtered orientation quaternion
float fbPl[3]
gyro offset (deg/s)
Quaternion fLPq
low pass filtered orientation quaternion
float fOmega[3]
average angular velocity (deg/s)
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
void fRun_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel)
#define FMAX_6DOF_GY_BPL
maximum permissible power on gyro offsets (deg/s)
This is the 3DOF basic accelerometer state vector structure.
float fqmErrPl[3]
geomagnetic vector tilt orientation quaternion error (dimensionless)
float fR[3][3]
unfiltered orientation matrix
The GyroSensor structure stores raw and processed measurements for a 3-axis gyroscope.
float fdeltat
sensor fusion interval (s)
#define CALIBRATION_NVM_ADDR
start of final 4K (sector size) of 1M flash
float fgdeltat
g (m/s2) * fdeltat
void f3DOFTiltAndroid(float fR[][3], float fGc[])
Android accelerometer 3DOF tilt function computing, rotation matrix fR.
int32_t systick
systick timer
float fLPRVec[3]
rotation vector
void fRun_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal)
int32_t systick
systick timer
Provides function prototypes for driver level interfaces.
void fQuaternionFromRotationMatrix(float R[][3], Quaternion *pq)
compute the orientation quaternion from a 3x3 rotation matrix
void fInit_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, float flpftimesecs)
void fInit_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel, float flpftimesecs)
void fRun_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct MagSensor *pthisMag, struct AccelSensor *pthisAccel)
float fLPChi
low pass tilt from vertical (deg)
void fmatrixAeqInvA(float *A[], int8 iColInd[], int8 iRowInd[], int8 iPivot[], int8 isize, int8 *pierror)
int32_t iValidMagCal
solver used: 0 (no calibration) or 4, 7, 10 element
float fbErrPl[3]
gyro offset error (deg/s)
SV_9DOF_GBY_KALMAN is the 9DOF Kalman filter accelerometer, magnetometer and gyroscope state vector s...
float fRVec[3]
rotation vector
Quaternion fq
unfiltered orientation quaternion
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)
void fQuaternionFromRotationVectorDeg(Quaternion *pq, const float rvecdeg[], float fscaling)
computes normalized rotation quaternion from a rotation vector (deg)
float fLPRVec[3]
rotation vector
SV_3DOF_Y_BASIC structure is the 3DOF basic gyroscope state vector structure.
void fNEDAnglesDegFromRotationMatrix(float R[][3], float *pfPhiDeg, float *pfTheDeg, float *pfPsiDeg, float *pfRhoDeg, float *pfChiDeg)
extract the NED angles in degrees from the NED rotation matrix
float fOmega[3]
angular velocity (deg/s)
void feCompassNED(float fR[][3], float *pfDelta, float *pfsinDelta, float *pfcosDelta, float fBc[], float fGc[], float *pfmodBc, float *pfmodGc)
NED: basic 6DOF e-Compass function, computing rotation matrix fR and magnetic inclination angle fDelt...
void f3DOFTiltWin8(float fR[][3], float fGc[])
Windows 8 accelerometer 3DOF tilt function computing, rotation matrix fR.
The SV_1DOF_P_BASIC structure contains state information for a pressure sensor/altimeter.
Math approximations file.
#define CHZ
Used to access Z-channel entries in various data data structures.
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor...
void fRun_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag)
void fRun_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure)
float fLPThe
low pass pitch (deg)
int8_t resetflag
flag to request re-initialization on next pass
float fBc[3]
averaged calibrated measurement (uT)
float fdeltat
fusion time interval (s)
Defines control sub-system.
float fRPl[3][3]
a posteriori orientation matrix
float flpf
low pass filter coefficient
The top level fusion structure.
float flpf
low pass filter coefficient
#define CHY
Used to access Y-channel entries in various data data structures.
SV_6DOF_GY_KALMAN is the 6DOF Kalman filter accelerometer and gyroscope state vector structure...
float fT
most recent unaveraged temperature (C)
int8_t resetflag
flag to request re-initialization on next pass
int32_t systick
systick timer
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
This is the 3DOF basic magnetometer state vector structure/.
void feCompassWin8(float fR[][3], float *pfDelta, float *pfsinDelta, float *pfcosDelta, float fBc[], float fGc[], float *pfmodBc, float *pfmodGc)
Win8: basic 6DOF e-Compass function, computing rotation matrix fR and magnetic inclination angle fDel...
float fRVecPl[3]
rotation vector
float fChiPl
tilt from vertical (deg)
quaternion structure definition
float fAlphaOver2
PI / 180 * fdeltat / 2.
float fOmega[3]
angular velocity (deg/s)
Functions to convert between various orientation representations.
float q3
z vector component
void fInit_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal)
int32_t systick
systick timer;
float fLPRVec[3]
rotation vector
float fYs[3]
averaged measurement (deg/s)
float fLPPsi
low pass yaw (deg)
float fLPPhi
low pass roll (deg)
float fRhoPl
compass (deg)
void fInit_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure, float flpftimesecs)
int8_t resetflag
flag to request re-initialization on next pass
#define FMIN_6DOF_GY_BPL
minimum permissible power on gyro offsets (deg/s)
float fDeltaPl
a posteriori inclination angle from Kalman filter (deg)
#define FLPFSECS_3DOF_G_BASIC
tilt orientation low pass filter time constant (s)
float fOmega[3]
average angular velocity (deg/s)
Quaternion fLPq
low pass filtered orientation quaternion
void feCompassAndroid(float fR[][3], float *pfDelta, float *pfsinDelta, float *pfcosDelta, float fBc[], float fGc[], float *pfmodBc, float *pfmodGc)
Android: basic 6DOF e-Compass function, computing rotation matrix fR and magnetic inclination angle f...
#define FLPFSECS_6DOF_GB_BASIC
float fLPRho
low pass compass (deg)
void fRotationVectorDegFromQuaternion(Quaternion *pq, float rvecdeg[])
computes rotation vector (deg) from rotation quaternion
float fLPR[3][3]
low pass filtered orientation matrix
float fLPThe
low pass pitch (deg)
float fLPPsi
low pass yaw (deg)
Matrix manipulation functions.
float fR[3][3]
unfiltered orientation matrix
The AccelSensor structure stores raw and processed measurements for a 3-axis accelerometer.
float flpf
low pass filter coefficient
float fLPDelta
low pass filtered inclination angle (deg)
float fQw9x9[9][9]
covariance matrix Qw
void fInit_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
float fqgErrPl[3]
gravity vector tilt orientation quaternion error (dimensionless)
float fZErr[3]
measurement error vector
int16_t iYs[3]
average measurement (counts)
The sensor_fusion.h file implements the top level programming interface.
int32_t systick
systick timer
Magnetic Calibration Structure.
float fLPT
low pass filtered temperature (C)
float fcosDeltaPl
cos(fDeltaPl)
float fLPChi
low pass tilt from vertical (deg)
Quaternion fq
unfiltered orientation quaternion
#define FQVG_9DOF_GBY_KALMAN
accelerometer sensor noise variance units g^2 defining minimum deviation from 1g sphere ...
float fAccGl[3]
linear acceleration (g) in global frame
#define FLPFSECS_3DOF_B_BASIC
2D eCompass orientation low pass filter time constant (s)
#define FQVY_9DOF_GBY_KALMAN
gyro sensor noise variance units (deg/s)^2
Quaternion fq
unfiltered orientation quaternion
Quaternion fq
unfiltered orientation quaternion
float fVelGl[3]
velocity (m/s) in global frame
void qAeqBxC(Quaternion *pqA, const Quaternion *pqB, const Quaternion *pqC)
function compute the quaternion product qB * qC
void f3x3matrixAeqI(float A[][3])
function sets the 3x3 matrix A to the identity matrix
float fOmega[3]
angular velocity (deg/s)
void fRotationMatrixFromQuaternion(float R[][3], const Quaternion *pq)
compute the rotation matrix from an orientation quaternion
float fDegPerSecPerCount
deg/s per count
Quaternion fqPl
a posteriori orientation quaternion
int16_t iYsFIFO[GYRO_FIFO_SIZE][3]
FIFO measurements (counts)
float fQwCT6x3[6][3]
Qw.C^T matrix.
float fQv6x1[6]
measurement noise covariance matrix leading diagonal
#define FLPFSECS_1DOF_P_BASIC
pressure low pass filter time constant (s)
The PressureSensor structure stores raw and processed measurements for an altimeter.
void fLPFOrientationQuaternion(Quaternion *pq, Quaternion *pLPq, float flpf, float fdeltat, float fOmega[])
function low pass filters an orientation quaternion and computes virtual gyro rotation rate ...
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
void fWin8AnglesDegFromRotationMatrix(float R[][3], float *pfPhiDeg, float *pfTheDeg, float *pfPsiDeg, float *pfRhoDeg, float *pfChiDeg)
extract the Windows 8 angles in degrees from the Windows 8 rotation matrix
#define GTOMSEC2
standard gravity in m/s2
void fveqRu(float fv[], float fR[][3], float fu[], int8 itranspose)
float fdeltat
fusion filter sampling interval (s)
void f3DOFTiltNED(float fR[][3], float fGc[])
Aerospace NED accelerometer 3DOF tilt function, computing rotation matrix fR.
float fdeltat
fusion time interval (s)
float fK9x6[9][6]
kalman filter gain matrix K
#define FQVG_6DOF_GY_KALMAN
accelerometer sensor noise variance units g^2
#define FQWB_6DOF_GY_KALMAN
gyro offset random walk units (deg/s)^2
float fLPThe
low pass pitch (deg)
#define FUSION_HZ
(int) actual rate of fusion algorithm execution and sensor FIFO reads
float fH
most recent unaveraged height (m)
float fLPPsi
low pass yaw (deg)
float fbPl[3]
gyro offset (deg/s)
float fR[3][3]
unfiltered orientation matrix
#define FMAX_9DOF_GBY_BPL
maximum permissible power on gyro offsets (deg/s)
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
void fInit_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag, float flpftimesecs)
#define FQVB_9DOF_GBY_KALMAN
magnetometer sensor noise variance units uT^2 defining minimum deviation from geomagnetic sphere...
float fRVecPl[3]
rotation vector
void fqAeqNormqA(Quaternion *pqA)
function normalizes a rotation quaternion and ensures q0 is non-negative
float fChi
tilt from vertical (deg)
float fQw6x6[6][6]
covariance matrix Qw
void fveqconjgquq(Quaternion *pfq, float fu[], float fv[])
#define FQVY_6DOF_GY_KALMAN
gyro sensor noise variance units (deg/s)^2
void fqAeq1(Quaternion *pqA)
set a quaternion to the unit quaternion
float fdeltat
sensor fusion interval (s)
void fRun_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
void fAndroidAnglesDegFromRotationMatrix(float R[][3], float *pfPhiDeg, float *pfTheDeg, float *pfPsiDeg, float *pfRhoDeg, float *pfChiDeg)
extract the Android angles in degrees from the Android rotation matrix
float fRhoPl
compass (deg)
int8_t iFirstAccelMagLock
denotes that 9DOF orientation has locked to 6DOF eCompass
int8_t resetflag
flag to request re-initialization on next pass
float fOmega[3]
virtual gyro angular velocity (deg/s)
float fLPPhi
low pass roll (deg)
float fLPPhi
low pass roll (deg)
float q1
x vector component
#define CHX
Used to access X-channel entries in various data data structures.
float fbErrPl[3]
gyro offset error (deg/s)
float fZErr[6]
measurement error vector
void f3DOFMagnetometerMatrixAndroid(float fR[][3], float fBc[])
Android magnetometer 3DOF flat eCompass function, computing rotation matrix fR.
float fdeltat
fusion time interval (s)
float fDisGl[3]
displacement (m) in global frame
void fInitializeFusion(SensorFusionGlobals *sfg)
float fqgErrPl[3]
gravity vector tilt orientation quaternion error (dimensionless)
float fLPR[3][3]
low pass filtered orientation matrix
float fLPR[3][3]
low pass filtered orientation matrix
void fInit_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV)
void fRun_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV, struct GyroSensor *pthisGyro)
float fLPRho
low pass compass (deg)
float fB
current geomagnetic field magnitude (uT)
float fGc[3]
averaged precision calibrated measurement (g)
#define FPIOVER180
degrees to radians conversion = pi / 180
float fLPRho
low pass compass (deg)
int32 ARM_systick_elapsed_ticks(int32 start_ticks)
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
uint8_t iFIFOCount
number of measurements read from FIFO
void f3x3matrixAeqB(float A[][3], float B[][3])
function sets 3x3 matrix A to 3x3 matrix B
float fAccGl[3]
linear acceleration (g) in global frame
float fLPChi
low pass tilt from vertical (deg)
float fQwCT9x6[9][6]
Qw.C^T matrix.
SV_6DOF_GB_BASIC is the 6DOF basic accelerometer and magnetometer state vector structure.
int8_t resetflag
flag to request re-initialization on next pass
void ARM_systick_start_ticks(int32 *pstart)
float fRPl[3][3]
a posteriori orientation matrix
float flpf
low pass filter coefficient
float fR[3][3]
unfiltered orientation matrix
Quaternion fqPl
a posteriori orientation quaternion
void f3DOFMagnetometerMatrixNED(float fR[][3], float fBc[])
Aerospace NED magnetometer 3DOF flat eCompass function, computing rotation matrix fR...
float fDelta
unfiltered inclination angle (deg)
float fsinDeltaPl
sin(fDeltaPl)
int8_t resetflag
flag to request re-initialization on next pass
#define FMIN_9DOF_GBY_BPL
minimum permissible power on gyro offsets (deg/s)
float fLPH
low pass filtered height (m)
int32_t systick
systick timer
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
void qAeqAxB(Quaternion *pqA, const Quaternion *pqB)
function compute the quaternion product qA = qA * qB
Lower level sensor fusion interface.
float fBSq
square of fB (uT^2)
#define FQWB_9DOF_GBY_KALMAN
gyro offset random walk units (deg/s)^2
int8_t resetflag
flag to request re-initialization on next pass
int32_t loopcounter
counter incrementing each iteration of sensor fusion (typically 25Hz)
float fChiPl
tilt from vertical (deg)
float fQv
measurement noise covariance matrix leading diagonal
float fAlphaOver2
PI / 180 * fdeltat / 2.
float fdeltat
fusion time interval (s)