This is a Parallax Propeller chip running a partial implementation of Premerlani and Bizard's work on Direction Cosine Matrix computation for orientation sensing. I'm hoping to use this in a quad-rotor without a GPS or magnetometer - I wanted to see how good the algorithm was at stabilizing pitch and roll. So far it looks very promising.
All the work is done on the Propeller itself. It reads the gyro and accelerometer values on one core, and computes the DCM from those readings on another core. At this point the code is still written in the high-level language, Spin. Since all the math is fixed point, there's a strong chance I won't actually have to write an assembly version - I haven't timed it yet, but my update loop is running at 200Hz, so it's at least that fast.
This post over at the Parallax Forums contains source:http://forums.parallax.com/showthread.php?131022-Propeller-DCM-Now-with-source
Comments
It might be moot - I've gotten the gyro drift down very low as it is. If you look at my other video (First Crash) toward the end, I take my hands off the remote and let it hover for 10 seconds or so. Heading and level don't really change, and that was without the DCM algorithm - just integrating the gyro readings.
This might be due to my (mis)understanding of how drift compensation works. I'm thinking that you compensate for drift on each gyro axis separately (as they would all be drifting at different/slowly varying rates anyhow).
If you are static and have a 'down vector' which has enough of a component in each of the XYZ axis/planes, then can you confirm/cancel out the drift for each axis separately (prior to using the gyro values in the DCM)?
I'm not suggesting this would be a solution for everyone, but for a slow moving quad it might work...
Simon.
I did mean just in the yaw direction... since it is just 'a degree every few seconds' you could try my 'to cheap for gps' idea. I mentioned this before a while ago and am too stubbon (or stupid ;-) to understand why it would not work for heli/quads. I never got it proven one way or the other...
If you place the sensor pack at a weird/offset angle, the gravity vector will be 'in' all of the gyros and will hence be able to compensate for drift. For normal level flight this should be stable, for short agressive manovers you might find that a gyro is uncompensated.
If you have a habit of continously flying in a tight circle you may have problems...
Simon
Stephen - I haven't decided yet whether to put a compass on it or not. I wanted to see how bad the drift was without it, since I'm planning on making this "augmented" flight, not completely autonomous.
I do plan on sharing the code, and so far it's written for readability as much as anything else. I started with a from-scratch implementation on the PC, then ported that to the prop once I had it all debugged. At present there's no control scheme of any kind - it's just the attitude estimator, but getting there from here shouldn't be too hard.
I'll post what I have within the next couple days. Sleep, work, and life need a little time right now - I've been up 'till 4am the past few nights getting this done. :)
If left flat on the table does it maintain correct rotation (on the screen) after a long period of time?
If not, what sort of duration does it take to become un-synced and does it self correct when (board is) moved?
Simon