Drift in Yaw using the Madgwick library, example

Hi,

  1. I see Yaw drift with the example code. using LSM6D3S library with Arduino cc.
  2. I looked at various forums and see that 9DoF using Magnetometer is used to compensate gyro.
  3. without magnetometer, the gyro could be calibrated?. Is this already part of this library [i could not find such code]
  4. and if not, is there any reason why it is not yet taken up?
  5. Meanwhile, Yaw starts at 180 and drifiting 1 degree angle reaches 0 and -180 and then back to 180. so its like 180 to -180 cycle keeps on repeating.

Thanks

Like all sensors, for accurate measurements the gyro must be calibrated. The usual way is to let the sensor sit still while you collect and average a few hundred readings for each gyro axis.

In the actual application, subtract the average from the raw measurements. If you don't make that correction, the reported orientation angles will tend to drift over time.

Angles repeat every 360 degrees.

Hi,

[1] Thanks for reply. This YAW data issue looks beyond averaging. [The first column values]

Orientation: 78.82 -1.90 0.49
Orientation: 78.41 -2.46 -0.53
Orientation: 77.94 -2.13 0.22
Orientation: 77.52 -2.16 -0.64
Orientation: 77.03 -2.00 0.29
Orientation: 76.62 -2.54 -0.73
Orientation: 76.14 -2.20 0.01
Orientation: 75.71 -1.82 -0.43
Orientation: 75.22 -1.84 0.68
Orientation: 74.80 -2.65 -0.33
Orientation: 74.34 -2.15 -0.03
Orientation: 73.94 -2.10 -0.87
Orientation: 73.44 -2.37 0.36
Orientation: 73.02 -2.31 -0.45
Orientation: 72.56 -1.81 -0.10
Orientation: 72.15 -3.15 -0.87
Orientation: 71.69 -2.71 -0.31
Orientation: 71.21 -2.31 0.34
Orientation: 70.80 -2.50 -0.60
Orientation: 70.32 -2.08 0.05
Orientation: 69.85 -1.55 0.16
Orientation: 69.41 -3.23 -0.17
Orientation: 68.96 -2.70 -0.06
Orientation: 68.52 -2.19 -0.07
Orientation: 68.10 -2.04 -0.79
Orientation: 67.60 -2.44 0.46
Orientation: 67.17 -2.25 -0.24
Orientation: 66.68 -3.04 1.01
Orientation: 66.26 -2.93 0.25
Orientation: 65.79 -2.40 0.55
Orientation: 65.36 -2.23 -0.18
Orientation: 64.94 -3.62 -0.89
Orientation: 64.49 -3.15 -0.49
Orientation: 64.02 -2.68 0.00
Orientation: 63.59 -2.24 -0.33
Orientation: 63.09 -2.45 0.88
Orientation: 62.66 -2.48 0.02

[2] for others, i can do averaging and smoothen them out.
[3] From data, is there anything which i am doing wrong. plz correct me.
[4] by "the reported orientation angles will tend to drift over time.", did you mean this kind of drift changing at every read .

Thanks

That is normal drift in yaw, the rotation about the vertical axis, because the sensor has no magnetometer to use as the yaw reference. With more careful gyro calibration, you might be able to slow the drift rate further.

For the other two angles, the accelerometer identifies the vertical direction as a reference.