Skip to content

Commit

Permalink
ensure cogYawGain is 1.0 except during gps rescue
Browse files Browse the repository at this point in the history
  • Loading branch information
ctzsnooze committed May 9, 2023
1 parent f4aad6c commit e00970b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/flight/imu.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ static void imuMahonyAHRSupdate(float dt, float gx, float gy, float gz,
}

const float ez_ef = cogYawGain * (- sin_approx(courseOverGround) * rMat[0][0] - cos_approx(courseOverGround) * rMat[1][0]);

ex = rMat[2][0] * ez_ef;
ey = rMat[2][1] * ez_ef;
ez = rMat[2][2] * ez_ef;
Expand Down Expand Up @@ -476,8 +475,8 @@ static void imuCalculateEstimatedAttitude(timeUs_t currentTimeUs)
static timeUs_t previousIMUUpdateTime;
bool useAcc = false;
bool useMag = false;
float cogYawGain = 0.0f; // Yaw correction Gain to be applied in imuMahonyAHRSupdate from our ground course
float courseOverGround = 0; // To be used when cogYawGain is non-zero. Stored in Radians
float cogYawGain = 1.0f; // Yaw correction gain to be applied in imuMahonyAHRSupdate from ground course
float courseOverGround = 0; // To be used when cogYawGain is non-zero, in radians

const timeDelta_t deltaT = currentTimeUs - previousIMUUpdateTime;
previousIMUUpdateTime = currentTimeUs;
Expand Down

0 comments on commit e00970b

Please sign in to comment.