68 sfg->SV_1DOF_P_BASIC.resetflag =
true;
71 sfg->SV_3DOF_B_BASIC.resetflag =
true;
74 sfg->SV_3DOF_G_BASIC.resetflag =
true;
77 sfg->SV_3DOF_Y_BASIC.resetflag =
true;
80 sfg->SV_6DOF_GB_BASIC.resetflag =
true;
83 sfg->SV_6DOF_GY_KALMAN.resetflag =
true;
86 sfg->SV_9DOF_GBY_KALMAN.resetflag =
true;
109 if (pthisSV_1DOF_P_BASIC)
119 if (pthisSV_3DOF_G_BASIC)
129 if (pthisSV_3DOF_B_BASIC)
139 if (pthisSV_3DOF_Y_BASIC)
149 if (pthisSV_6DOF_GB_BASIC)
159 if (pthisSV_6DOF_GY_KALMAN)
168 #if F_9DOF_GBY_KALMAN 169 if (pthisSV_9DOF_GBY_KALMAN)
173 pthisGyro, pthisMagCal);
190 if (flpftimesecs > pthisSV->
fdeltat)
193 pthisSV->
flpf = 1.0F;
196 pthisSV->
fLPH = pthisPressure->
fH;
197 pthisSV->
fLPT = pthisPressure->
fT;
206 struct AccelSensor *pthisAccel,
float flpftimesecs)
212 if (flpftimesecs > pthisSV->
fdeltat)
215 pthisSV->
flpf = 1.0F;
218 #if THISCOORDSYSTEM == NED 220 #elif THISCOORDSYSTEM == ANDROID 234 struct MagSensor *pthisMag,
float flpftimesecs)
240 if (flpftimesecs > pthisSV->
fdeltat)
243 pthisSV->
flpf = 1.0F;
246 #if THISCOORDSYSTEM == NED 248 #elif THISCOORDSYSTEM == ANDROID 278 struct MagSensor *pthisMag,
float flpftimesecs)
286 if (flpftimesecs > pthisSV->
fdeltat)
289 pthisSV->
flpf = 1.0F;
292 #if THISCOORDSYSTEM == NED 294 #elif THISCOORDSYSTEM == ANDROID 325 for (i =
CHX; i <=
CHZ; i++)
335 if (*((
uint32 *) pFlash++) == 0x12345678)
338 for (i =
CHX; i <=
CHZ; i++) pthisSV->
fbPl[i] = *(pFlash++);
344 for (i =
CHX; i <=
CHZ; i++)
348 pthisSV->
fbPl[i] = pthisGyro->
fYs[i];
350 pthisSV->
fbPl[i] = 0.0F;
356 #if THISCOORDSYSTEM == NED 358 #elif THISCOORDSYSTEM == ANDROID 390 for (i =
CHX; i <=
CHZ; i++) {
394 pthisSV->
fVelGl[i] = 0.0F;
395 pthisSV->
fDisGl[i] = 0.0F;
402 if (*((
uint32*) pFlash++) == 0x12345678) {
404 for (i =
CHX; i <=
CHZ; i++)
405 pthisSV->
fbPl[i] = *(pFlash++);
409 for (i =
CHX; i <=
CHZ; i++) {
411 pthisSV->
fbPl[i] = pthisGyro->
fYs[i];
413 pthisSV->
fbPl[i] = 0.0F;
421 #if THISCOORDSYSTEM == NED 423 pthisMag->
fBc, pthisAccel->
fGc, &ftmp, &ftmp);
424 #elif THISCOORDSYSTEM == ANDROID 426 pthisMag->
fBc, pthisAccel->
fGc, &ftmp, &ftmp);
429 pthisMag->
fBc, pthisAccel->
fGc, &ftmp, &ftmp);
458 pthisSV->
fLPH += pthisSV->
flpf * (pthisPressure->
fH - pthisSV->
fLPH);
459 pthisSV->
fLPT += pthisSV->
flpf * (pthisPressure->
fT - pthisSV->
fLPT);
476 #if THISCOORDSYSTEM == NED 478 #elif THISCOORDSYSTEM == ANDROID 494 #if THISCOORDSYSTEM == NED 498 #elif THISCOORDSYSTEM == ANDROID 525 #if THISCOORDSYSTEM == NED 527 #elif THISCOORDSYSTEM == ANDROID 543 #if THISCOORDSYSTEM == NED 547 #elif THISCOORDSYSTEM == ANDROID 591 #if THISCOORDSYSTEM == NED 594 &(pthisSV->
fRho), &(pthisSV->
fChi));
595 #elif THISCOORDSYSTEM == ANDROID 598 &(pthisSV->
fRho), &(pthisSV->
fChi));
602 &(pthisSV->
fRho), &(pthisSV->
fChi));
611 float ftmp1, ftmp2, ftmp3, ftmp4;
622 #if THISCOORDSYSTEM == NED 624 #elif THISCOORDSYSTEM == ANDROID 640 #if THISCOORDSYSTEM == NED 644 #elif THISCOORDSYSTEM == ANDROID 667 float ftmp3DOF3x1[3];
668 float ftmpA3x3[3][3];
695 for (i =
CHX; i <=
CHZ; i++)
696 pthisSV->
fOmega[i] = (
float) pthisGyro->
iYs[i] *
702 fqMi = pthisSV->
fqPl;
712 for (i =
CHX; i <=
CHZ; i++)
713 ftmpMi3x1[i] = (
float) pthisGyro->
iYsFIFO[j][i] *
732 fmodGc = sqrtf(fabs(pthisAccel->
fGc[
CHX] * pthisAccel->
fGc[
CHX] +
738 ftmp = 1.0F / fmodGc;
739 ftmp3DOF3x1[
CHX] = pthisAccel->
fGc[
CHX] * ftmp;
740 ftmp3DOF3x1[
CHY] = pthisAccel->
fGc[
CHY] * ftmp;
741 ftmp3DOF3x1[
CHZ] = pthisAccel->
fGc[
CHZ] * ftmp;
746 ftmp3DOF3x1[
CHX] = 0.0F;
747 ftmp3DOF3x1[
CHY] = 0.0F;
748 ftmp3DOF3x1[
CHZ] = 1.0F;
752 #if THISCOORDSYSTEM == NED 754 #elif THISCOORDSYSTEM == ANDROID 756 ftmp3DOF3x1[
CHX] = -ftmp3DOF3x1[
CHX];
757 ftmp3DOF3x1[
CHY] = -ftmp3DOF3x1[
CHY];
758 ftmp3DOF3x1[
CHZ] = -ftmp3DOF3x1[
CHZ];
764 ftmpMi3x1[
CHX] = 2.0F * (fqMi.
q1 * fqMi.
q3 - fqMi.
q0 * fqMi.
q2);
765 ftmpMi3x1[
CHY] = 2.0F * (fqMi.
q2 * fqMi.
q3 + fqMi.
q0 * fqMi.
q1);
766 ftmpMi3x1[
CHZ] = 2.0F * (fqMi.
q0 * fqMi.
q0 + fqMi.
q3 * fqMi.
q3) - 1.0F;
769 #if THISCOORDSYSTEM == NED 771 #else // ANDROID and WIN8 773 ftmpMi3x1[
CHX] = -ftmpMi3x1[
CHX];
774 ftmpMi3x1[
CHY] = -ftmpMi3x1[
CHY];
775 ftmpMi3x1[
CHZ] = -ftmpMi3x1[
CHZ];
789 for (i = 0; i < 6; i++)
790 for (j = 0; j < 6; j++) pthisSV->
fQw6x6[i][j] = 0.0F;
834 ftmp = fmodGc - 1.0F;
835 fQvGQa = 3.0F * ftmp * ftmp;
841 for (i = 0; i < 6; i++)
843 for (j = 0; j < 3; j++)
848 for (k = 0; k < 6; k++)
852 if (k == j) fC3x6jk = 1.0F;
856 if ((pthisSV->
fQw6x6[i][k] != 0.0F) && (fC3x6jk != 0.0F))
868 for (i = 0; i < 3; i++)
870 for (j = i; j < 3; j++)
874 ftmpA3x3[i][j] = pthisSV->
fQv;
876 ftmpA3x3[i][j] = 0.0F;
879 for (k = 0; k < 6; k++)
883 if (k == i) fC3x6ik = 1.0F;
887 if ((fC3x6ik != 0.0F) && (pthisSV->
fQwCT6x3[k][j] != 0.0F))
890 ftmpA3x3[i][j] += pthisSV->
fQwCT6x3[k][j];
892 ftmpA3x3[i][j] += fC3x6ik * pthisSV->
fQwCT6x3[k][j];
899 ftmpA3x3[1][0] = ftmpA3x3[0][1];
900 ftmpA3x3[2][0] = ftmpA3x3[0][2];
901 ftmpA3x3[2][1] = ftmpA3x3[1][2];
904 for (i = 0; i < 3; i++) pfRows[i] = ftmpA3x3[i];
911 for (i = 0; i < 6; i++)
913 for (j = 0; j < 3; j++)
915 pthisSV->
fK6x3[i][j] = 0.0F;
916 for (k = 0; k < 3; k++)
918 if ((pthisSV->
fQwCT6x3[i][k] != 0.0F) &&
919 (ftmpA3x3[k][j] != 0.0F))
921 pthisSV->
fK6x3[i][j] += pthisSV->
fQwCT6x3[i][k] * ftmpA3x3[k][j];
930 for (i = 0; i < 6; i++)
932 for (j = 0; j < 3; j++)
934 pthisSV->
fK6x3[i][j] = 0.0F;
941 for (i =
CHX; i <=
CHZ; i++)
950 if (pthisSV->
fK6x3[i][CHZ] != 0.0F)
954 if (pthisSV->
fK6x3[i + 3][
CHX] != 0.0F)
958 if (pthisSV->
fK6x3[i + 3][
CHY] != 0.0F)
960 if (pthisSV->
fK6x3[i + 3][CHZ] != 0.0F)
968 ftmp = ftmpq.
q1 * ftmpq.
q1 + ftmpq.
q2 * ftmpq.
q2 + ftmpq.
q3 * ftmpq.
q3;
974 ftmpq.
q0 = sqrtf(fabsf(1.0F - ftmp));
979 ftmp = 1.0F / sqrtf(ftmp);
996 for (i =
CHX; i <=
CHZ; i++)
1012 #if THISCOORDSYSTEM == NED 1017 #elif THISCOORDSYSTEM == ANDROID 1028 #if THISCOORDSYSTEM == NED 1032 #elif THISCOORDSYSTEM == ANDROID 1043 #if F_9DOF_GBY_KALMAN 1052 float ftmpA6x6[6][6];
1059 float ftmpA3x3[3][3];
1069 float fsinDelta6DOF;
1070 float fcosDelta6DOF;
1096 fqMi = pthisSV->
fqPl;
1102 for (j = 0; j < pthisGyro->
iFIFOCount; j++) {
1121 #if THISCOORDSYSTEM == NED 1122 feCompassNED(fR6DOF, &fDelta6DOF, &fsinDelta6DOF, &fcosDelta6DOF, pthisMag->
fBc, pthisAccel->
fGc, &fmodBc, &fmodGc);
1123 #elif THISCOORDSYSTEM == ANDROID 1124 feCompassAndroid(fR6DOF, &fDelta6DOF, &fsinDelta6DOF, &fcosDelta6DOF, pthisMag->
fBc, pthisAccel->
fGc, &fmodBc, &fmodGc);
1126 feCompassWin8(fR6DOF, &fDelta6DOF, &fsinDelta6DOF, &fcosDelta6DOF, pthisMag->
fBc, pthisAccel->
fGc, &fmodBc, &fmodGc);
1133 ftmp = fmodGc - 1.0F;
1134 fQvGQa = 3.0F * ftmp * ftmp;
1139 ftmp = fmodBc - pthisMagCal->
fB;
1140 fQvBQd = 3.0F * ftmp * ftmp;
1148 fqMi = pthisSV->
fqPl = fq6DOF;
1158 #if THISCOORDSYSTEM == NED 1165 #else // ANDROID and WIN8 (ENU gravity positive) 1183 #if THISCOORDSYSTEM == NED 1184 ftmpA3x1[
CHX] = fR6DOF[
CHX][
CHX] * fcosDelta6DOF + fR6DOF[
CHX][
CHZ] * fsinDelta6DOF;
1185 ftmpA3x1[
CHY] = fR6DOF[
CHY][
CHX] * fcosDelta6DOF + fR6DOF[
CHY][
CHZ] * fsinDelta6DOF;
1186 ftmpA3x1[
CHZ] = fR6DOF[
CHZ][
CHX] * fcosDelta6DOF + fR6DOF[
CHZ][
CHZ] * fsinDelta6DOF;
1190 #else // ANDROID and WIN8 (both ENU coordinate systems) 1191 ftmpA3x1[
CHX] = fR6DOF[
CHX][
CHY] * fcosDelta6DOF - fR6DOF[
CHX][
CHZ] * fsinDelta6DOF;
1192 ftmpA3x1[
CHY] = fR6DOF[
CHY][
CHY] * fcosDelta6DOF - fR6DOF[
CHY][
CHZ] * fsinDelta6DOF;
1193 ftmpA3x1[
CHZ] = fR6DOF[
CHZ][
CHY] * fcosDelta6DOF - fR6DOF[
CHZ][
CHZ] * fsinDelta6DOF;
1210 for (i = 0; i < 9; i++)
1211 for (j = i; j < 9; j++)
1212 pthisSV->
fQw9x9[i][j] = 0.0F;
1246 for (i = 1; i < 9; i++)
1247 for (j = 0; j < i; j++)
1256 for (i = 0; i < 9; i++) {
1257 for (j = 0; j < 6; j++) {
1260 for (k = 0; k < 9; k++) {
1265 if (k == j) fC6x9jk = 1.0F;
1266 if (k == (j + 6)) fC6x9jk = -pthisSV->
fAlphaOver2;
1269 if (k == j) fC6x9jk = 1.0F;
1270 if (k == (j + 3)) fC6x9jk = -pthisSV->
fAlphaOver2;
1274 if ((pthisSV->
fQw9x9[i][k] != 0.0F) && (fC6x9jk != 0.0F)) {
1275 if (fC6x9jk == 1.0F) pthisSV->
fQwCT9x6[i][j] += pthisSV->
fQw9x9[i][k];
1283 for (i = 0; i < 6; i++) {
1284 for (j = i; j < 6; j++) {
1286 if (i == j) ftmpA6x6[i][j] = pthisSV->
fQv6x1[i];
1287 else ftmpA6x6[i][j] = 0.0F;
1289 for (k = 0; k < 9; k++) {
1294 if (k == i) fC6x9ik = 1.0F;
1295 if (k == (i + 6)) fC6x9ik = -pthisSV->
fAlphaOver2;
1298 if (k == i) fC6x9ik = 1.0F;
1299 if (k == (i + 3)) fC6x9ik = -pthisSV->
fAlphaOver2;
1303 if ((fC6x9ik != 0.0F) && (pthisSV->
fQwCT9x6[k][j] != 0.0F)) {
1304 if (fC6x9ik == 1.0F) ftmpA6x6[i][j] += pthisSV->
fQwCT9x6[k][j];
1305 else ftmpA6x6[i][j] += fC6x9ik * pthisSV->
fQwCT9x6[k][j];
1311 for (i = 1; i < 6; i++)
1312 for (j = 0; j < i; j++)
1313 ftmpA6x6[i][j] = ftmpA6x6[j][i];
1316 for (i = 0; i < 6; i++)
1317 pfRows[i] = ftmpA6x6[i];
1323 for (i = 0; i < 9; i++)
1324 for (j = 0; j < 6; j++) {
1325 pthisSV->
fK9x6[i][j] = 0.0F;
1326 for (k = 0; k < 6; k++) {
1327 if ((pthisSV->
fQwCT9x6[i][k] != 0.0F) && (ftmpA6x6[k][j] != 0.0F))
1328 pthisSV->
fK9x6[i][j] += pthisSV->
fQwCT9x6[i][k] * ftmpA6x6[k][j];
1333 for (i = 0; i < 9; i++)
1334 for (j = 0; j < 6; j++)
1335 pthisSV->
fK9x6[i][j] = 0.0F;
1340 for (i =
CHX; i <=
CHZ; i++) {
1342 for (j = 0; j < 6; j++) {
1344 if (pthisSV->
fK9x6[i][j] != 0.0F)
1348 if (pthisSV->
fK9x6[i + 3][j] != 0.0F)
1352 if (pthisSV->
fK9x6[i + 6][j] != 0.0F)
1361 ftmpq.
q0 = sqrtf(fabs(1.0F - ftmpq.
q1 * ftmpq.
q1 - ftmpq.
q2 * ftmpq.
q2 - ftmpq.
q3 * ftmpq.
q3));
1366 fveqRu(fgPl, ftmpA3x3, fgMi, 0);
1372 ftmpq.
q0 = sqrtf(fabs(1.0F - ftmpq.
q1 * ftmpq.
q1 - ftmpq.
q2 * ftmpq.
q2 - ftmpq.
q3 * ftmpq.
q3));
1377 fveqRu(fmPl, ftmpA3x3, fmMi, 0);
1381 #if THISCOORDSYSTEM == NED// gravity vector is +z and accel measurement is +z when flat so don't negate 1383 fmPl, fgPl, &fmodBc, &fmodGc);
1384 #elif THISCOORDSYSTEM == ANDROID // gravity vector is -z and accel measurement is +z when flat so negate 1385 ftmpA3x1[
CHX] = -fgPl[
CHX];
1386 ftmpA3x1[
CHY] = -fgPl[
CHY];
1387 ftmpA3x1[
CHZ] = -fgPl[
CHZ];
1389 fmPl, ftmpA3x1, &fmodBc, &fmodGc);
1390 #else // WIN8// gravity vector is -z and accel measurement is -1g when flat so don't negate 1392 fmPl, fgPl, &fmodBc, &fmodGc);
1400 for (i =
CHX; i <=
CHZ; i++) {
1419 #if THISCOORDSYSTEM == NED 1424 #elif THISCOORDSYSTEM == ANDROID 1437 for (i =
CHX; i <=
CHZ; i++) {
1445 #if THISCOORDSYSTEM == NED 1447 #elif THISCOORDSYSTEM == ANDROID 1455 #endif // #if F_9DOF_GBY_KALMAN float fGc[3]
averaged precision calibrated measurement (g)
#define FMIN_6DOF_GY_BPL
minimum permissible power on gyro offsets (deg/s)
#define FLPFSECS_6DOF_GB_BASIC
float fLPRVec[3]
rotation vector
float fDeltaPl
a posteriori inclination angle from Kalman filter (deg)
void fRun_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure)
int32_t iValidMagCal
solver used: 0 (no calibration) or 4, 7, 10 element
void fmatrixAeqInvA(float *A[], int8 iColInd[], int8 iRowInd[], int8 iPivot[], int8 isize, int8 *pierror)
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
float fChi
tilt from vertical (deg)
void f3DOFMagnetometerMatrixNED(float fR[][3], float fBc[])
Aerospace NED magnetometer 3DOF flat eCompass function, computing rotation matrix fR...
void fRotationMatrixFromQuaternion(float R[][3], const Quaternion *pq)
compute the rotation matrix from an orientation quaternion
float fOmega[3]
angular velocity (deg/s)
void fInitializeFusion(SensorFusionGlobals *sfg)
#define FMIN_9DOF_GBY_BPL
minimum permissible power on gyro offsets (deg/s)
float fVelGl[3]
velocity (m/s) in global frame
#define CHY
Used to access Y-channel entries in various data data structures.
void f3DOFTiltNED(float fR[][3], float fGc[])
Aerospace NED accelerometer 3DOF tilt function, computing rotation matrix fR.
int32_t systick
systick timer
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
float fQw6x6[6][6]
covariance matrix Qw
#define CALIBRATION_NVM_ADDR
start of final 4K (sector size) of 1M flash
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
float fR[3][3]
unfiltered orientation matrix
float fQv6x1[6]
measurement noise covariance matrix leading diagonal
float fdeltat
fusion time interval (s)
void fRun_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct MagSensor *pthisMag, struct AccelSensor *pthisAccel)
#define FLPFSECS_3DOF_G_BASIC
tilt orientation low pass filter time constant (s)
float fRVecPl[3]
rotation vector
void f3x3matrixAeqB(float A[][3], float B[][3])
function sets 3x3 matrix A to 3x3 matrix B
float fK6x3[6][3]
kalman filter gain matrix K
#define FQWB_9DOF_GBY_KALMAN
gyro offset random walk units (deg/s)^2
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 fsinDeltaPl
sin(fDeltaPl)
float fDegPerSecPerCount
deg/s per count
float fYs[3]
averaged measurement (deg/s)
float fQv
measurement noise covariance matrix leading diagonal
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
Lower level sensor fusion interface.
#define FPIOVER180
degrees to radians conversion = pi / 180
float fbPl[3]
gyro offset (deg/s)
#define FMAX_6DOF_GY_BPL
maximum permissible power on gyro offsets (deg/s)
float fLPPsi
low pass yaw (deg)
Functions to convert between various orientation representations.
int16_t iYs[3]
average measurement (counts)
float fbErrPl[3]
gyro offset error (deg/s)
#define FQVY_6DOF_GY_KALMAN
gyro sensor noise variance units (deg/s)^2
float fRPl[3][3]
a posteriori orientation matrix
float fRPl[3][3]
a posteriori orientation matrix
float fH
most recent unaveraged height (m)
void fRun_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag)
float fOmega[3]
average angular velocity (deg/s)
float fbPl[3]
gyro offset (deg/s)
int16_t iYsFIFO[GYRO_FIFO_SIZE][3]
FIFO measurements (counts)
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 q1
x vector component
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...
int32_t systick
systick timer
float fLPPhi
low pass roll (deg)
float fLPRVec[3]
rotation vector
Quaternion fLPq
low pass filtered orientation quaternion
float fQw9x9[9][9]
covariance matrix Qw
float fdeltat
fusion time interval (s)
This is the 3DOF basic magnetometer state vector structure/.
Quaternion fq
unfiltered orientation quaternion
#define FQVB_9DOF_GBY_KALMAN
magnetometer sensor noise variance units uT^2 defining minimum deviation from geomagnetic sphere...
void fQuaternionFromRotationMatrix(float R[][3], Quaternion *pq)
compute the orientation quaternion from a 3x3 rotation matrix
void fqAeq1(Quaternion *pqA)
set a quaternion to the unit quaternion
int8_t resetflag
flag to request re-initialization on next pass
The AccelSensor structure stores raw and processed measurements for a 3-axis accelerometer.
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
float fQwCT6x3[6][3]
Qw.C^T matrix.
float fRVecPl[3]
rotation vector
Quaternion fq
unfiltered orientation quaternion
SV_9DOF_GBY_KALMAN is the 9DOF Kalman filter accelerometer, magnetometer and gyroscope state vector s...
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 ...
void f3DOFMagnetometerMatrixWin8(float fR[][3], float fBc[])
Windows 8 magnetometer 3DOF flat eCompass function, computing rotation matrix fR. ...
float fDelta
unfiltered inclination angle (deg)
float fRVec[3]
rotation vector
void fInit_9DOF_GBY_KALMAN(struct SV_9DOF_GBY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, struct GyroSensor *pthisGyro, struct MagCalibration *pthisMagCal)
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor...
#define GTOMSEC2
standard gravity in m/s2
#define FQVG_6DOF_GY_KALMAN
accelerometer sensor noise variance units g^2
void fQuaternionFromRotationVectorDeg(Quaternion *pq, const float rvecdeg[], float fscaling)
computes normalized rotation quaternion from a rotation vector (deg)
The top level fusion 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 fT
most recent unaveraged temperature (C)
The SV_1DOF_P_BASIC structure contains state information for a pressure sensor/altimeter.
float fgdeltat
g (m/s2) * fdeltat
float fAccGl[3]
linear acceleration (g) in global frame
void fInit_3DOF_B_BASIC(struct SV_3DOF_B_BASIC *pthisSV, struct MagSensor *pthisMag, float flpftimesecs)
float fLPR[3][3]
low pass filtered orientation matrix
float flpf
low pass filter coefficient
#define FLPFSECS_3DOF_B_BASIC
2D eCompass orientation low pass filter time constant (s)
float fAlphaOver2
PI / 180 * fdeltat / 2.
SV_6DOF_GY_KALMAN is the 6DOF Kalman filter accelerometer and gyroscope state vector structure...
int8_t iFirstAccelMagLock
denotes that 9DOF orientation has locked to 6DOF eCompass
void fRun_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV, struct GyroSensor *pthisGyro)
int32_t systick
systick timer
void qAeqBxC(Quaternion *pqA, const Quaternion *pqB, const Quaternion *pqC)
function compute the quaternion product qB * qC
float fLPThe
low pass pitch (deg)
float fR[3][3]
unfiltered orientation matrix
float fLPChi
low pass tilt from vertical (deg)
float fR[3][3]
unfiltered orientation matrix
float fLPR[3][3]
low pass filtered orientation matrix
float fLPPhi
low pass roll (deg)
int8_t resetflag
flag to request re-initialization on next pass
void fInit_6DOF_GB_BASIC(struct SV_6DOF_GB_BASIC *pthisSV, struct AccelSensor *pthisAccel, struct MagSensor *pthisMag, float flpftimesecs)
int32 ARM_systick_elapsed_ticks(int32 start_ticks)
Quaternion fqPl
a posteriori orientation quaternion
void fveqconjgquq(Quaternion *pfq, float fu[], float fv[])
int32_t systick
systick timer
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
Math approximations file.
void fInit_1DOF_P_BASIC(struct SV_1DOF_P_BASIC *pthisSV, struct PressureSensor *pthisPressure, float flpftimesecs)
float fR[3][3]
unfiltered orientation matrix
Quaternion fq
unfiltered orientation quaternion
int8_t resetflag
flag to request re-initialization on next pass
float fQwCT9x6[9][6]
Qw.C^T matrix.
float fdeltat
fusion filter sampling interval (s)
float fZErr[6]
measurement error vector
Quaternion fqPl
a posteriori orientation quaternion
The sensor_fusion.h file implements the top level programming interface.
int32_t systick
systick timer;
SV_3DOF_Y_BASIC structure is the 3DOF basic gyroscope state vector structure.
float flpf
low pass filter coefficient
float fLPT
low pass filtered temperature (C)
#define CHZ
Used to access Z-channel entries in various data data structures.
#define FMAX_9DOF_GBY_BPL
maximum permissible power on gyro offsets (deg/s)
Matrix manipulation functions.
Provides function prototypes for driver level interfaces.
float flpf
low pass filter coefficient
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
#define FQVY_9DOF_GBY_KALMAN
gyro sensor noise variance units (deg/s)^2
void f3DOFTiltAndroid(float fR[][3], float fGc[])
Android accelerometer 3DOF tilt function computing, rotation matrix fR.
float fOmega[3]
average angular velocity (deg/s)
#define FQWB_6DOF_GY_KALMAN
gyro offset random walk units (deg/s)^2
void fInit_3DOF_Y_BASIC(struct SV_3DOF_Y_BASIC *pthisSV)
float fLPRho
low pass compass (deg)
int8_t resetflag
flag to request re-initialization on next pass
float fB
current geomagnetic field magnitude (uT)
float fOmega[3]
angular velocity (deg/s)
float fLPR[3][3]
low pass filtered orientation matrix
float fZErr[3]
measurement error vector
float fAlphaOver2
PI / 180 * fdeltat / 2.
float fOmega[3]
virtual gyro angular velocity (deg/s)
void fRun_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel)
float fChiPl
tilt from vertical (deg)
#define CHX
Used to access X-channel entries in various data data structures.
Quaternion fLPq
low pass filtered orientation quaternion
float fOmega[3]
angular velocity (deg/s)
float fLPThe
low pass pitch (deg)
void fveqRu(float fv[], float fR[][3], float fu[], int8 itranspose)
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
void fInit_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
float fRhoPl
compass (deg)
void f3x3matrixAeqI(float A[][3])
function sets the 3x3 matrix A to the identity matrix
float q2
y vector component
float fBc[3]
averaged calibrated measurement (uT)
float fqmErrPl[3]
geomagnetic vector tilt orientation quaternion error (dimensionless)
Magnetic Calibration Structure.
Quaternion fLPq
low pass filtered orientation quaternion
int8_t resetflag
flag to request re-initialization on next pass
float fRhoPl
compass (deg)
void fInit_3DOF_G_BASIC(struct SV_3DOF_G_BASIC *pthisSV, struct AccelSensor *pthisAccel, float flpftimesecs)
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 fqAeqNormqA(Quaternion *pqA)
function normalizes a rotation quaternion and ensures q0 is non-negative
float fcosDeltaPl
cos(fDeltaPl)
quaternion structure definition
float fLPRVec[3]
rotation vector
float fbErrPl[3]
gyro offset error (deg/s)
#define FUSION_HZ
(int) actual rate of fusion algorithm execution and sensor FIFO reads
float fdeltat
sensor fusion interval (s)
Defines control sub-system.
float fBSq
square of fB (uT^2)
void fRotationVectorDegFromQuaternion(Quaternion *pq, float rvecdeg[])
computes rotation vector (deg) from rotation quaternion
float fdeltat
fusion time interval (s)
float fLPRho
low pass compass (deg)
float fChiPl
tilt from vertical (deg)
float fqgErrPl[3]
gravity vector tilt orientation quaternion error (dimensionless)
float fLPChi
low pass tilt from vertical (deg)
float fqgErrPl[3]
gravity vector tilt orientation quaternion error (dimensionless)
float q3
z vector component
void fRun_6DOF_GY_KALMAN(struct SV_6DOF_GY_KALMAN *pthisSV, struct AccelSensor *pthisAccel, struct GyroSensor *pthisGyro)
float flpf
low pass filter coefficient
float fLPPsi
low pass yaw (deg)
float fLPRho
low pass compass (deg)
float fdeltat
fusion time interval (s)
SV_6DOF_GB_BASIC is the 6DOF basic accelerometer and magnetometer state vector structure.
#define FLPFSECS_1DOF_P_BASIC
pressure low pass filter time constant (s)
void f3DOFTiltWin8(float fR[][3], float fGc[])
Windows 8 accelerometer 3DOF tilt function computing, rotation matrix fR.
float fLPChi
low pass tilt from vertical (deg)
void qAeqAxB(Quaternion *pqA, const Quaternion *pqB)
function compute the quaternion product qA = qA * qB
This is the 3DOF basic accelerometer state vector structure.
float fLPThe
low pass pitch (deg)
float fLPPsi
low pass yaw (deg)
int8_t resetflag
flag to request re-initialization on next pass
uint8_t iFIFOCount
number of measurements read from FIFO
int32_t loopcounter
counter incrementing each iteration of sensor fusion (typically 25Hz)
The GyroSensor structure stores raw and processed measurements for a 3-axis gyroscope.
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)
int32_t systick
systick timer;
float fDisGl[3]
displacement (m) in global frame
float fLPH
low pass filtered height (m)
int8_t resetflag
flag to request re-initialization on next pass
float fdeltat
sensor fusion interval (s)
void ARM_systick_start_ticks(int32 *pstart)
float fK9x6[9][6]
kalman filter gain matrix K
float fLPDelta
low pass filtered inclination angle (deg)
void f3DOFMagnetometerMatrixAndroid(float fR[][3], float fBc[])
Android magnetometer 3DOF flat eCompass function, computing rotation matrix fR.
#define FQVG_9DOF_GBY_KALMAN
accelerometer sensor noise variance units g^2 defining minimum deviation from 1g sphere ...
Quaternion fq
unfiltered orientation quaternion
The PressureSensor structure stores raw and processed measurements for an altimeter.
float fLPPhi
low pass roll (deg)
float fAccGl[3]
linear acceleration (g) in global frame
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