Jump to content
I2Cdevlib Forums

MPU-9250 madgwick filter drift


Recommended Posts

For my project i need a way to determine correct orientation of the rocket.

I took code for Madgwick filter from here

https://github.com/morgil/madgwick_py

for collecting data i used Arduino Nano + MPU9250 sensor. This setup sends packets every 12ms to my PC via Serial.

I calibrated magnetometer by calculating biases to "align" axis origin and center of sphere, created by set of measurements.

Then i drew coordinate axis with blender: 

vjSwg.png

and coded some script for it - quaternion.py It just reads values from serial, feeds them into Filter, and then rotates my axis object using quaternion rotation mode.

I screwed up with orientation of model's X axis a little bit, so when i rotate my board clockwise, axis on the screen rotates counter-clockwise. I flipped signs of all X components, and it became fine.

According to this picture 

4emM3.png

 i flipped X and Y axis and sign of Z axis, to align axis of magnetometer with gyroscope + accelerometer

And it almost works with one small exception - when after "stabilization" i tilt i.e. X axis downwards (or Y axis, doesnt matter) this axis starts drifting toward global X-Y plane. If i tilt axis upwards, remaining axis starts drifting around global O-Z axis, like this 

X axis downwards

lJ8uL.png

And when x axis upwards

cCmLt.png

Speed of that drift depends on Beta of Madgwick filter - the more beta the more drift.

What can be done there?

Edited by Jl06CTEP
add code for script
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...