Skip to content

Commit 68fd01d

Browse files
Gyroscope input using degrees/sec (not radians)
1 parent b35912d commit 68fd01d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/MadgwickAHRS.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ void Madgwick::update(float gx, float gy, float gz, float ax, float ay, float az
5858
return;
5959
}
6060

61+
// Convert gyroscope degrees/sec to radians/sec
62+
gx *= 0.0174533f;
63+
gy *= 0.0174533f;
64+
gz *= 0.0174533f;
65+
6166
// Rate of change of quaternion from gyroscope
6267
qDot1 = 0.5f * (-q1 * gx - q2 * gy - q3 * gz);
6368
qDot2 = 0.5f * (q0 * gx + q2 * gz - q3 * gy);
@@ -151,6 +156,11 @@ void Madgwick::updateIMU(float gx, float gy, float gz, float ax, float ay, float
151156
float qDot1, qDot2, qDot3, qDot4;
152157
float _2q0, _2q1, _2q2, _2q3, _4q0, _4q1, _4q2 ,_8q1, _8q2, q0q0, q1q1, q2q2, q3q3;
153158

159+
// Convert gyroscope degrees/sec to radians/sec
160+
gx *= 0.0174533f;
161+
gy *= 0.0174533f;
162+
gz *= 0.0174533f;
163+
154164
// Rate of change of quaternion from gyroscope
155165
qDot1 = 0.5f * (-q1 * gx - q2 * gy - q3 * gz);
156166
qDot2 = 0.5f * (q0 * gx + q2 * gz - q3 * gy);

0 commit comments

Comments
 (0)