Wednesday, February 6, 2013

PC Visualization Test - Rotating PCB

Not it's getting really close to start wit the "real" functions in the system. I'm currently testing the Madgwick AHRS algorithm, with success however I realized that his quaternion derivative is at fault. Firstly he uses the left hand derivative (why? fixed by changing the sign of the derivative) and secondly he uses the equation for when the angular rate is measured in the fixed frame, not in the PCB frame. This creates strange effects when rotating a lot but I changed this and the result can be seen in the following videos comparing Madgwick rotation and my fixed rotation.

Madgwick rotation:

Correct rotation:

And when using the correct derivative the following C# program was created to visualize the result using OpenTK:

Now it's really starting to come together!

2 comments:

  1. Hi,
    I have also looked into Madgwick AHRS algorithm and found an error. I read that you too have some bugs in this code. I my case the varaibles _2bx and _2bz are wrongly calculated.
    The following lines have to be inserted:
    _2bx = 2.0f * _2bx;
    _2bz = 2.0f * _2bz;

    Is this rhe same as you spotted?
    Finally, where can I find your conference paper?

    Regards,
    Göran Andersson



    ReplyDelete
  2. Hi!

    No, this error I have not noticed yet. Mine was that the derivative had the wrong sign in the equations.
    My paper can be found here: http://pure.ltu.se/portal/sv/publications/full-quaternion-based-attitude-control-for-a-quadrotor(b7c373fb-df19-45eb-a2f1-3a104b4ffb3d).html
    For more information, please send me an email! I will soon post about the article as well.

    ReplyDelete