# DCM Algorithm vs Direct Integration

Hi Everyone.
I am new to this forum... long time reader, first time poster. I hope to contribute to the community.

My question is regarding the DCM algorithm:
I have simulated Bill's DCM algorithm in MatLAB/Simulink, and it seems, that direct integration always meets or exceeds the DCM integration/multiplication. See results below:

It seems while simply integrating the said non-linear differentials, I find the results to be of better accuracy and MUCH LESS processing power!! So why even use the DCM orientation integration? What are the advantages?

Please note: In this simulation, I have intentionally not yet taken into account the PI drift correction (because, no matter what pre-algorithm you use, in the long run, post PI correction will always give you the correct orientation).

Thanks
-Hassan

Views: 1538

### Replies to This Discussion

Could you please describe in mathematical form, what "direct integration" means?

Consider the following gyro input:
90 times (dx:1 degree, dy:0, dz:0) (I mean it turns 90 degree on the x axis in 90 steps)
90 times (dx:0, dy:1,dz:0)
90 times (dx:-1, dy:0,dz:0)
90 times (dx:0,dy:-1,dz:0)
What is the final orientation? :-)

regards, Jozsef
Hi mmormota

What I mean by "direct integration", is just a discrete integral (also represented as SIGMA in mathematics).
So since, the gyro outputs in [deg/s], if you integrate the gyro, you will get [deg], aka the orientation.

(90-90,90-90,0) = (0,0,0) [deg]

:D
Ok. (I was not sure and suspect a more fancy algorithm)

As Bill replied, that's just not correct.
Worth to make a small experiment with a box or something, no computer, no integration just turn it in your hands. Turn it according to the data, and check the final orientation. Absolutely not 0,0,0. :-)
btw.. here is a higher resolution pic:
http://i26.tinypic.com/2h3dhs7.png
Hi Hassan,

Welcome aboard!!

If you push direct integration, you will eventually discover what the problem is with it.

At the heart of it, the problem with direct integration is that finite rotations are not commutative. That is just a fancy way of saying that the order of rotations is important. That is what Jozsef was saying.

For example, lets consider the combination of a 90 degree pitch upward, and a 90 degree roll to the right, as seen by the gyros, which are measuring the rotation rates in the plane frame of reference.

Suppose the pitch is first done first, followed by the roll. In that case, the plane will be pointing straight up.

Then, suppose that the roll is done first, followed by the pitch upward in the plane frame of reference. In that case, the plane will be pointing level, with one wing up, and one wing down.

Those are two entirely different situations.

The bottom line is that for finite rotations, the direct integration method gradually accumulates large errors in attitude estimation.

Best regards,
Bill
Hi Bill,
I see I see... very very interesting.

Thanks guys,
-Hassan
Hi Hassan,

If you do some research, you will find that direct integration does not work. It is a well known fact.

There is a test case that might help you see it. Perform the following rotations, starting with the plane flying north, wings level. Keep in mind that each rotation is described and measured in the frame of reference of the plane:

1. Do a quick yaw clockwise of 90 degrees.

2. Do a quick roll of 180 degrees.

3. Do a quick yaw clockwise of 90 degrees.

The actual result is that the plane will be flying north, upside down. This is what the DCM algorithm will compute.

However, direct integration will conclude that the plane is flying south.

Best regards,
Bill
You were right! It really shocked me (as I am an Electrical Engineer and not mechanical)
Check out my results here: http://www.youtube.com/watch?v=E7XVvv8XHgI

I am in the progress of redesigning my control algorithm for my quadrotor, and will surly be implementing this method. I will post the flow-charts/Simulink algorithm once its close to done.

Best Regards,
-Hassan

I've just come across this thread and I'm still not clear on what the original poster means by "direct integration." What do you mean by direct integration?

DCM just directly integrates the differential equation:

dr/dt=w x r.

Also, that's a system of three linear ODEs. There isn't anything nonlinear about the differential equation for rotational kinematics.

Perhaps he is applying the rotation matrices sequentially?

If you express w as a skew symmetric matrix, you can solve the differential equation for the kinematics by taking the matrix exponential of the matrix version of w (\Omega). The integrating factor approach to solving the first order ODE is related to the exponential map that takes the Lie algebra so(3) to the Lie group SO(3). You end up with an exact matrix that you can multiply the DCM by at each time step. Since this matrix (exp(\Omega)) is a member of SO(3), there is no need to renormalize at each time step. This is mostly of pedagogical value, however, since the use of the infinitesimal rotation matrix along with renormalization is faster.

So what do people mean by "direct integration?"

Also, I'm puzzled by people referring to the ODE for rotational kinematics as nonlinear.

-Scott

SCott,

The OP was just assuming that omega = d theta / dt (where theta is pitch, roll, or yaw attitude), as opposed to your correct coupled formulation. Since the cross product can be parameterized as a matrix, I think you are correct that the equation is linear. I just never thought of it that way before.

- Roy

So he was applying finite rotation matrices sequentially, using \theta_x=wx*dt, \theta+y=wy*dt, \theta_z=wz*dt? It wasn't clear what he was doing and I currently don't have Simulink so I couldn't load up his models.

Applying a single rotation matrix given by exponentiating the skew-symmetric representation of w does work. You form the finite rotation matrix that rotates about the instantaneous axis of rotation.

Yeah, the kinematics are linear. They have the form

L(r)=0 where L is the operator D=d/dt+w x.

Written in matrix form, you just get a linear system of ODEs:

dr/dt=\Omega r, where \Omega is the skew-symmetric matrix.

It's linear, just non-abelian.

Solving the ODE in closed form and using that to update the DCM is more accurate, but much more computationally expensive. It's not worth it unless you have tons of processing power to spare. I've implemented it in Matlab just for completeness.

It is fun to see the deep connection between Lie groups, Lie algebras, and differential equations in action.

-Scott

Scott,

I've seen some papers that discuss "invariant observers" that I believe are based on the idea of keeping the product in SO(3). Do you have a reference that describes what you mean, or can you at least type out the equation? I think you mean somethinng like this:

expm(A),

where m is for Matrix, and A is the skew-symmetric matrix form of omega

0             -omegaz   omegay

A = omegaz        0            -omegax

-omegay        omegax      0

Does expm(A) have a closed form solution? Is the first order approximation any different than multiplying by I + A dt then renormalizing? Actually, I think that would be identical, from a Taylor series approach. How about if we add the next term - something like A^2/2?

- Roy

1

2

3

4

5

6

7

8

9

10

## Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

51 members

136 members

51 members

185 members

24 members