Skip to content

Commit 209e8a0

Browse files
committed
updates
1 parent f69a3da commit 209e8a0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/flight/imu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static float imuCalculateMcCogAccWeight(void)
358358
{
359359
fpVector3_t accBFNorm;
360360
vectorScale(&accBFNorm, &imuMeasuredAccelBFFiltered, 1.0f / GRAVITY_CMSS);
361-
float wCoGAcc = constrainf((accBFNorm.z - 1.0f)* 2, 0.0f, 1.0f);
361+
float wCoGAcc = constrainf((accBFNorm.z - 1.0f)* 2, 0.0f, 1.0f); //z direction is verified via SITL
362362
return wCoGAcc;
363363
}
364364

@@ -441,7 +441,7 @@ static void imuMahonyAHRSupdate(float dt, const fpVector3_t * gyroBF, const fpVe
441441
}
442442
#endif
443443
wCoG *= scaleRangef(constrainf((airSpeed+gpsSol.groundSpeed)/2, 400, 1000), 400, 1000, 0.0f, 1.0f);
444-
} else { //then vCOGAcc is not null
444+
} else { //vCOG is not avaliable and vCOGAcc is avaliable, set the weight of vCOG to zero
445445
wCoG = 0.0f;
446446
}
447447
if (STATE(MULTIROTOR)){
@@ -469,7 +469,7 @@ static void imuMahonyAHRSupdate(float dt, const fpVector3_t * gyroBF, const fpVe
469469
vHeadingEF.z = 0.0f;
470470

471471
// We zeroed out vHeadingEF.z - make sure the whole vector didn't go to zero
472-
if (vectorNormSquared(&vHeadingEF) > 0.01f) {
472+
if (vectorNormSquared(&vHeadingEF) > 0.01f && vectorNormSquared(&vCoGlocal) > 0.01f) {
473473
// Normalize to unit vector
474474
vectorNormalize(&vHeadingEF, &vHeadingEF);
475475
vectorNormalize(&vCoGlocal, &vCoGlocal);

0 commit comments

Comments
 (0)