T3

### robust estimator of the direction cosine matrix

#### Replies

• Dear Bill

"Magnetometer is used for yaw compensation."

Thanks

• T3

Johnson,

There are several methods for using a magnetometer for gyro drift compensation. Here is the method that I like to use:

1. Transform the 3D measured magnetic field vector from body frame to earth frame.

2. Take the cross product of the horizontal plane projections of actual and measured earth frame magnetic field vectors. This gives you the sine of the yaw error angle. Call this the yaw correction in earth frame.

3. Transform the earth frame yaw correction vector back into body frame and use it for gyro drift compensation.

http://diydrones.com/page/uav-devboard

Best regards,

Bill

• Bill

thanks very much .

I got it.

thanks

• Dear
I have new questions
regarding the RollPitchCorrection ,we use the accelerometer to obtain a gravity reference vector
question 1:
when we use it ,is there an assumption made that the plane keep going forward in a horizontal level?
question 2:
we take the cross product Z row of estimated DCM with the gravity reference vector
and if the result is not ZERO, you call it RollPitch error
but I wonder is there also Yaw error in the DCM certainly? why do we not call it RollPitchYaw error?
is it known as RollPitch error not RollPitchYaw error ?

question 3:
respectively in the GPS setion, why we call it YawCollection? if Yaw need collect, i think the others(Roll,Pitch)also need

question 4:
in GPS section,YawCorrection
you use the X column of the DCM,that means the projection of xb of plane in the earth reference frame.
and then use the COG vector which is also treated in the earth frame.
but why only the Z component of the cross product of these two vector is seen as rotational correction?
actually I don't know much about the Yaw error(/collection) after I read this GPS section.
in my own understanding ,Yaw error means the Z Row of the estimated DCM is not aligned with the vertical gravity vector both in Plane frame's view. and at the same time as I mentioned in question 2, the Roll ,Pitch is also has errors
why these errors are seperately explained in different section. why I think 3 axis is supposed to have the errors at the same time .
all of 3 axis have errors
or
all of 3 axis do not have errors
would you please give me some explanation?

• Very sorry to trouble you so many times.
I have understood and let me answer some of the question myself.

>question 2:
>we take the cross product Z row of estimated DCM with the gravity reference vector
>and if the result is not ZERO, you call it RollPitch error
>but I wonder is there also Yaw error in the DCM certainly? why do we not call it RollPitchYaw error?
>is it known as RollPitch error not RollPitchYaw error ?

>question 3:
>respectively in the GPS setion, why we call it YawCollection? if Yaw need collect, i think the others(Roll,Pitch)also need

>question 4:
>in GPS section,YawCorrection
>you use the X column of the DCM,that means the projection of xb of plane in the earth reference frame.
>and then use the COG vector which is also treated in the earth frame.
>but why only the Z component of the cross product of these two vector is seen as rotational correction?

firstly keep it in mind that the GPS COG vector in the earth fram is always located in the X-Y horizontal
vector like [x,y,0]
when we refer to the GPS COG, we focus the direction the plane is pointing
if it has a error(a deviation from GPS COS) we have to correct it.
simpliy we rotate the roll-axis,of cource we can not rotate only 1 axis due to the direction cosine matrix property
so the pitch has to be rotated correspondedly.but the yaw-axis do not have to .
this correction we call it YawCorrection.
OK,because GPS COS is horizontal, so we only need to calculate the cross prodcut of XBp and COG
which happends to be the Z component of cross product of XB and COG
if we use the whole cross of XB and COG, as a result ,we will rotate the Yaw-axis,that is not supposed to be.

OK I hope this will help other newers.

Thanks.

regarding COG and roll-axis, we only need the Z component

while gravity and  Z row of DCM, we nee the whole cross product

may i know the reason

• Dear I have new questions regarding the RollPitchCorrection we use the accelerometer to obtain a reference vector ( the Z-axis in plane frame) and the assumption is made that the

• Dear

Regarding the Eqn 26 in the paper(DcmDraft2)

I think

the acceleromter is aligned with the plane(body).so its output is the combination result of gravity and centrigual acceleration.

and we only need the gravity acceleration as our reference vector.

so the equation should be (Vector) as follows?

g_reference = Acceleration - centrigual acceleration

I confused with the Eqn26

Thanks.

• T3

Johnson,

Regarding renormalization introducing drift, in practice, it does not create much drift. I have done static (motionless) tests on the UDB5 hardware with drift correction turned off and measured the residual drift from all sources (such as noise, renormalization, offset shift) to be on the order of one degree per minute. There are much larger sources of error in flight due to gyro calibration errors. See for example:

http://diydrones.com/profiles/blogs/sustained-rotations-pushing

In any case, you need to apply continual drift compensation in flight to prevent accumulation of attitude estimation error. This is done with the aid of known reference vectors.

Regarding the bottom row of the matrix, it represents the image of the earth vertical axis in the body frame. You can use the accelerometer as a reference vector for vertical if you compensate for centrifugal acceleration. There are a couple of ways of doing that, DCMDraft2 describes one way to do it, the following describes another way:

http://diydrones.com/forum/topics/an-improved-method-for-accounting...

Regarding the interpretation of the sign of the accelerometer data, depending on your preference, you can think of it as producing gravity minus acceleration, or acceleration minus gravity. I have been told by some of the members of the MatrixPilot team that the way that I think of it is opposite to the rest of the world, so I apologize if I have confused you.

Finally, here is another source of information on this subject, it is nicely organized, fun to read and easy to understand:

http://www.starlino.com/dcm_tutorial.html

Best regards,

Bill