I'm looking for some kind of filter, algorithm which will allow me to compensate gyro yaw drift using heading of magnetometer. My project requires only yaw measurments and both sensors are flat. Is there any simple solution or i need to dig into more complicated filtering?

I've got acc in my system but i think it's not necessary for this task.

  • $\begingroup$ Welcome to Robotics! Don’t forget to mark answers as solutions if you feel they solve your problem. $\endgroup$ Commented Jul 27, 2019 at 17:13

1 Answer 1


Your best would be using the Madgwick filter, as its already implemented in several languages and programs. Yaw, pitch or roll can then be easily called from the filter.

Follow the link to a description from adafruit and their library.

  • $\begingroup$ As far as i know , madgwick filter can be used only when accel is present and needed and that's not my case. I want to fuse only gyro and mag data $\endgroup$
    – akimata
    Commented Jul 27, 2019 at 17:54
  • $\begingroup$ You dont need mag data to fuse with for gyro drift...however does the chip you have, not have accel built in? Or is this an exercise in developing a technique for explicitly gyro and mag? You say you have acc, gyro and mag..i dint see why you wouldnt use all three for a more robust system. $\endgroup$ Commented Jul 27, 2019 at 18:12
  • $\begingroup$ @akimata unless you are at one of Earth's poles the rotation of the Earth will cause your system to rotate along all three axis. $\endgroup$
    – fibonatic
    Commented Jul 29, 2019 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.