# DCM IMU Theory : first draft

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: 20123

Tags: DCM

T3
Comment by William Premerlani on September 24, 2009 at 8:04am
Silenced,
I had some experience with magnetometers 6 years ago, but nothing recent. They can be used to compensate for yaw gyro drift, but they have some issues. You have to calibrate them and keep them away from magentic steel and current carrying wires. Also, there are some parameters that depend on your location.
Bill
Comment by silenced on September 27, 2009 at 4:19am
bill,

i am interested in better understanding your method of renormalization. my initial guess wrt your 'scaling' is that it is some form of numerical approximation of dividing a vector by its length.

what i cannot figure out is the theory behind the cross-coupled elimination of the dot product error. could you enlighten further on this?

thanks!

T3
Comment by William Premerlani on September 27, 2009 at 12:51pm
Silenced:

I implement the scaling by taking the first two terms (constant plus derivate) in the Taylor's expansion for the reciprocal of the square root of the sums of the squares around 1.0. Since the vector lengths start out at 1.0, this approach maintains the lengths close to 1.0 at all times. I did it this way to avoid a division step that is not really necesary.

The cross-coupled elimination of the dot product error is more interesting: The idea is that the three rows and columns will always be approximately perpendicular, because we are gong to maintain them that way, and we are going to maintain their lengths to be one. We are left with a slight rotational error, which is perpendicular to the vector. For example, suppose vectors A and B are almost, but not exactly perpendicular, and we want to adjust them to make them closer to perpendicular. We do not want to change their magnitude, we just want to rotate them. That means the adjustment to each of them is perpendicular. Since B is perpendicular to A, when we want to rotate A a little bit, we simply add a portion of B. And vice-versa when we want to rotate B.

We take the dot product of the A and B to find out if they are perpendicular. If they are, the dot product will be zero. If not, the dot product will be measure of how much they have to be rotated toward or away from each other to be perpendicular. Since we have no way of knowing whether A or B are more likely to be correct, we split the difference, and adjust both A and B by 1/2 of the dot product.

Best regards,
Bill
Comment by chan on October 31, 2009 at 2:05am
i want to measure the tile angles (roll and pitch) with 5D IMU (3 axis accelerometer and 2 axis gyro). is there any fusion algorithm for pic microcontroller?.

T3
Comment by William Premerlani on October 31, 2009 at 3:05pm
Chan,

Sorry, I cannot help you. Lately all of my work has been with a 3 axis accelerometer and a 3 axis gyro.

Hopefully, someone else who has done work with a 3 axis accelerometer and a 2 axis gyro will answer your question. I know a few people who tried it but they did not achieve very good results.

I assume that you plan to use the 2 gyros that you have to measure roll and pitch, and that you are going to ignore yaw all together.

The problem is, if the airframe is yawing while the roll and pitch angles are not zero, the roll and pitch gyros will measure a portion of the yaw rate. Without an estimate of the yaw, you will erroneously conclude that the roll and pitch angles are changing, when in fact they are not.

Best regards,
Bill
Comment by Abdulrahman Sabbagh on February 1, 2010 at 3:16pm
That's really great work! but can a helicopter make yaw lock using only a tilt compensated compass and no gyros at all ? Thank you

T3
Comment by William Premerlani on February 2, 2010 at 1:16pm
Hi Abdulrahman,

If you have a tilt compensated compass, you can determine yaw, but it is not easy to achieve tilt compensation without gyros, accelerometers, and centrifugal compensation.

Bill
Comment by Abdulrahman Sabbagh on February 2, 2010 at 1:31pm
Hi William, thanks for replying to my post on such short notice, the tilt compensation compass has a built-in 3d magentometers and 3d accelerometers and gives compensated heading output, the compass module is from sparkfun:
http://www.sparkfun.com/commerce/product_info.php?products_id=8656.
So what do you think?
Comment by Abdulrahman Sabbagh on February 2, 2010 at 1:34pm
My question is, are gyros really necessary? accelerometers can be used to determine tilts on 3 axis, so why the need of gyros? my compass module gives digital precise outputs of tilted angles without the need of further calculations. Thank you

T3
Comment by William Premerlani on February 2, 2010 at 4:53pm
Hi Abdulrahman,

The problem with accelerometers is they have tilt error when they are accelerating, because what they measure is gravity minus acceleration. So, they are fine on the ground, I am not so sure how well they might work in a helicopter. So an accelerometer based tilt compensated compass might work ok in a hover, but you might have trouble during a banked turn.

What is typically done for tilt compensation during accelerated motion is to combine accelerometer information with gyro information, and to use gyro information to compensate for centrifugal effects on the accelerometers.

Best regards,
Bill

Comment

Join DIY Drones

1

2

3

4

5

6

7

8

9

10

## Groups

74 members

26 members

1789 members

315 members

• ### ArduPlane User Group

875 members

Season Two of the Trust Time Trial (T3) Contest has now begun. The fifth round, 3D model building requiring contestants to survey and reconstruct a building or natural scene from aerial images.

A list of all T3 contests is here.