For those of you who are trying to understand the "direction-cosine-matrix" algorithm, or who are struggling to understand Mahony's papers or the firmware for my UAV DevBoard, a first draft of the document, Direction Cosine Matrix IMU: Theory, is now available. It is a work in progress. Although Paul Bizard and I have not yet incorporated all of the great suggestions we received from reviewers, especially from Louis LeGrand and UFO-MAN, I think there is an audience for what we have so far.

Views: 36767

Comment by John_Mac on May 17, 2009 at 9:05pm

Excellent paper! As you may remember, I am interested in applying DCM to Helis. Am I correct in assuming that your approach will work for Helis even though you are applying Mahony's formalism to aircraft for which the dynamics are different, but you do not include dynamics....only kinematics?

Thanks for sharing all your work.
Comment by Ho-Chung Chang on May 18, 2009 at 1:41am
Excellent paper! I have been trying to understand the code and paper articles.
If passible, would you mind I translate relation articles into Chinese.
Comment by Hugo Vincent on May 18, 2009 at 2:32am
Great work Bill! It's so good to see such an accessible guide to this material, I am sure many people will learn from it greatly.

First, one thing (and yes, it's pedantic, but hey, we're engineers :-) -- I find your usage of the term "DCM" or "direction cosine matrix" really confusing! You use it interchangably to refer to DCMs as representations of rotation (like you might use the terms quaternion or Euler angles), and to refer to your Mahoney-derived complementary filter for attitude estimation (that happens to be formulated in terms of DCM representations of attitude).

Second, what is the advantage of DCM for attitude representation over quaternions? You mention that they are a better fit for control or navigation without really explaining why. I don't think DCMs are particularly much more intuitive than quaternions (personally, I find only Euler angles intuitive... I convert DCM or quaternions back to Euler angles while debugging to get that intuition). It seems to me that quaternions would lead to a computationally-simpler estimator, which is important here (on diydrones) as we tend to use small CPUs lacking heaps of power and memory. But I haven't compared the computational cost of fixed-point implementations... does the cost of doing more trig operations outweigh the lower arithmetic cost?

Finally, other than simplicity of understanding is there an advantage of these complementary filters over traditional Kalman based INS algorithms? Stability/robustness? In their various forms, they seem to be gaining traction in the low-cost IMU segment, even in PhD-level research groups etc where the additional complexity of coding up a Kalman filter wouldn't be a problem at all. Yet, they don't even come close to attaining theoretical optimality in estimation, as a (correct, extended/nonlinear) Kalman filter would.

Thanks for all your work!

Hugo Vincent

Comment by William Premerlani on May 18, 2009 at 3:07am

Yes, my approach will work for helicopters, for which I would recommend magnetometers for yaw control. Also, as you mentioned, I implemented only the first half of Mahony's approach that deals with computing attitude. That is more than adequate for airplanes.

For helicopters, you might want to implement Mahony's full approach, you will have an elegant control solution as well, but you will have to prepare a model of the aircraft dynamics.

Comment by William Premerlani on May 18, 2009 at 3:09am
@Ho-Chung Chang,
Everything that I publish at diydrones is open-source. Go ahead and translate it, if you want.
Comment by Manor A. on May 18, 2009 at 3:09am
Some people are there to make the world a better place.
I agree with Hugo about using the term DCM, it is a bit clashing with the usual conventions. Nevertheless it is a remarkable effort and it is remarkable when people are sharing such an effort.
I promise to go over this and see if I can contribute.

Thanks Bill and Paul

Comment by William Premerlani on May 18, 2009 at 3:50am
@Hugo Vincent

Sorry for overloading the term "DCM". In what is to follow in this comment, I will use DCM to refer to the matrix, and DCM algorithm to refer to attitude estimation based on DCM.

Regarding DCM and quaternion based approaches, they produce nearly identical performance, they are based on the same underlying rotation group. Mahony's papers are expressed both in terms of quaternions and in terms of DCM. Paul Bizard and I considered both representations when we started. I was in favor of DCM because of fond memories of the teachings of a favorite college professor, so that is the one we used. We could have just as well used quaternions.

Quaternions are slightly more computationally efficient than DCM, requiring about 2/3 as many multiplies and adds, but both methods are much more computationally efficient than Kalman based algorithms. I endorse both quaternions and DCM. I think it is a matter of taste which one to use. Personally, I think in terms of direction cosines, not Euler angles, and I find it convenient to express all control and navigation calculations in terms of dot and cross products of vectors with the rows and columns of the matrix. But if you prefer quaternions, I will not argue the point.

Regarding Kalman approaches, Paul Bizard has done a side-by-side comparison of the DCM algorithm with extended Kalman filtering (EKF). The DCM algorithm is simpler and much more computationally efficient. EKF will tolerate a larger initial gyro offset than the DCM algorithm, but once the algorithms achieve "gyro lock", they produce nearly identical results. Basically, either way will produce highly accurate attitude estimates, with excellent transient response.

I do not consider the edge that EKF has with regard to initial gyro offset to be worth the disadvantages of EKF, because if your aircraft is motionless during power up, the intial gyro offset is small. After that, both EKF and the DCM algorithm are more than capable of keeping up with changes in gyro offset due to changes in temperature or supply voltage.

I know that some folks perform temperature compensation of their gyros. With the DCM algorithm, you can ignore gyro drift due to temperature changes, and not bother with the temperature compensation.
Comment by Joseph Glanville on May 18, 2009 at 6:02am
Wow! Incredible paper hehe.
This approach is substantially more elegant and cleaner than Kalman filtering. :)
Comment by Howard Gordon on May 18, 2009 at 7:20am
Bill -

Very nice explanation. The only issue I have with your approach is the use of GPS instead of a compass for yaw correction. A compass gives you instantaneous heading information, while GPS data requires integration over time and (as you have noted) introduces additional latencies. Also, a GPS provides no useful heading information if the airframe is hovering.

Comment by William Premerlani on May 18, 2009 at 8:02am

Basically I agree with you, a compass is nice to have, especially if the airframe is hovering, or if you want to do agressive aerobatics with a helicopter. In that case, a compass is the only way to go.

However, I have tried compasses, I found there were a lot of headaches with calibrating them and keeping them away from sources of error. In the end, since my main interest is not helicopters, I abandoned them in favor of GPS plus gyros and accelerometers.

If the airframe does not hover, GPS works well enough with the DCM algorithm, even in windy conditions, since it is only doing gyro drift correction. Since you need the GPS anyway for location information, if you can also use it for yaw information, you can avoid the need for a compass. I have gotten good reports from several folks who are using my DCM firmware in forward moving airframes. Also, I have been using GPS, gyros and accelerometers without a compass for several years to control a model saiplane, it works quite well. Finally, I note that lots of folks have been getting good performance with Chris Anderson's ArduPilot, without a compass.

GPS does introduce additional latencies, but it is not as bad as I originally reported. There is a quirk in the binary interface to the EM406 GPS that incurs a 12 second latency at 4800 baud. If you run at 19,200 or higher, the latency drops down to a couple of seconds.

By the way, I have used GPS without a compass to steer a model truck, it does just fine. It wanders a little bit starting from a dead stop, but the trajectory is smooth because of stabilization from the gyros. As the truck picks up speed, the accuracy of the GPS course-over-ground information improves at just the right rate to keep pace with the requirements.

The bottom line is that, although I agree with you that for some applications a compass is the only way to go, there are plenty of applications where a compass is really not needed.


You need to be a member of DIY Drones to add comments!

Join DIY Drones


Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2017   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service