recently I tried to measure yaw angle with MPU6050 and MahonyAHRS algorithm. As expected, the yaw angle consistently drifts.

But I could see that the changes caused by the drift are much smaller than the changes caused by real movements. So I put a simple if sentence to check whether the change is bigger than a threshold, if yes it is not a drift, if not it is a drift so don't add up.

yaw_change = read_yaw() - yaw_lastvalue
if yaw_change > threshold_for_drift :
    yaw = yaw_startvalue + yaw_change

But it cant be that simple ? Is there any disadvantage for catching the drift in this way? Smaller movements than drift can be ignored in my case.

  • 1
    $\begingroup$ Besides the fact you'd have to constantly be checking and correcting for this...what happens if you plan to go a specific direction very slowly. How do you intend to tell the difference between a threshold and a specific wanted change in yaw? Although people do use something like this to help filter out instantaneous spikes...for long term changes you're going to find this doesn't work..and what about your short term wanted changes...how do you intend to tell the difference with a simple if statement? $\endgroup$ – morbo Aug 13 '19 at 18:11
  • $\begingroup$ @morbo So as long as the drift is small enough so that it is always smaller than my desired movement this method is ok. If other people have already used this, they have certainly put a fancy name on that. Do you know how they call it? $\endgroup$ – Joe Aug 14 '19 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.