### Sebastian O.H. Madgwick's Filter in action

i have been struggling with gyro drift and up to now no real solution exists.

it effects the pirates and the newer arducopter2 code base because both build upon the same dcm implementation.

i played around with the pirate code base and could improve the situation a little bit.

and after a few trials i decided to replace the current dcm implementation by the quaternion solution from sebastian madgwick.

what i need is some more tuning and a better pilot :)

there was quite a bit of wind today. and gusty wind between the rain showers.

• hi roy,

to me it was amazing - i did not spend too much time on putting everything together. the video itself is made on the first day without crashes. my main problem area was the error feedback for the pid pwm calculation (actually only pi). here i prob. make an other change to simplify things.

computationally it is amazing - i upped the mainloop frequency up to 333 hz and my newer copter flew nicely. the older one is dead now ;-)

robert

• Robert,

Sebastian is on DiyDrones

See http://diydrones.com/forum/topics/a-computationally-inexpensive?xg_...

His own conclusion:
"Conclusion:Mayhony’s algorithm is computationally less expensive and more ‘elegant’. In my own work, I now use Mayhony’s for these reason but I combine it with my ‘magnetic distortion compensation’ algorithm for the reasons given above."

Note that in the video you linked, the poster claims he may not have implmented te Mahony DCM correctly.

Note also that quaternions require less computational effort in the sense that they only require 1 constraint to be enforced, since they have only one "redundant" parameter, whereas orientation matrix (DCM) has 6 extra parameters and associated constraints. But, rotating a vector is much cheaper for DCM than for quaternions. Which is the better chpoice depends on which tasks you need to perform.

- Roy
• @ken

pls. read jason's comment on gyrodrift

the quaternions might be a tad to non magic ;-)

sebastion claims it is not subject to accumulate errors: demonstration

comparison of methods

to me the integrator as is has a few flaws. the most important one is it introduces a delay and delays create an instable system. those delays are visible as low frequent whobbles in the air.

at the moment i need to increase the convergence of the gyroscope bias.

• I rather like quaternions too, but I don't think they're magic enough to fix gyro drift...
• Forgive my ignorance, but I have a few questions (which I hope are neither too dumb nor too forward). How much drift are you talking about, a few degrees per second? Shouldn't that be fixed with a magnetometer? Isn't the quaternion version the same algorithm just applied with quats instead of matricies? If it is the same algorithm, why would there be a difference in performance? Are you suggesting that this DCM implementation has a bug?

Thanks, again sorry if they are stupid questions. Either way, I am partial to quaternions.

• Congratulations!  I have been working through the quaternion math in an effort to replace APM_DCM with a Quaternion equivalent.  Well done that you made it happen!
• Developer
quaternions are a much better approach.  A lot less overhead!
• thanks!
yes, i will publish the code.
i need more time to tune the parameters.
takes more time as expected.
• Hi Robert,

Congratulations to your implementation. I hope we will see some longer video in the next time.

Is it possible to see the code of your solution?

By the way, it seems that your test area has exactly the same immense dimensions like mine ;)