LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How does LabVIEW calculate Euler Angles from Direction Cosine Matrix?

Solved!
Go to solution

I'm looking to clean up my block diagram by converting LabVIEW math functions to Mathscript; however, I can't find out exactly which rotation convention is being used to calculate Euler angles from the Direction Cosine Matrix. Any ideas?

Here's what I'm using now (see below)... the phi angle is the only one (of three angles) not correcting like the LabVIEW math functions. I've also attached the .vi that demonstrates the calculation both ways.

 

%calculate Euler angles from DCM

%'DCM' is a 3x3 direction cosine matrix

 

phi = atan((DCM(2,3))/(DCM(3,3)));

theta = acos(DCM(3,3));

psi = atan2(DCM(1,3),DCM(2,3));

0 Kudos
Message 1 of 15
(5,134 Views)

BenMedeiros,

 

Here is our documentation on that Driection Cosine Matrix: http://zone.ni.com/reference/en-XX/help/371361D-01/gmath/euler_angles_to_direction_cosines/

it includes the formula as well.

 

If you decide to use the 3D cartesian Rotation VI you can find that info here: http://zone.ni.com/reference/en-XX/help/371361G-01/gmath/3d_cartesian_coord_rotation_direction/

 

🙂 I hope this helps

Sam S
Applications Engineer
National Instruments
0 Kudos
Message 2 of 15
(5,105 Views)

Hi Sam,

 

Thanks for the reply. I've looked at that example in the link you provided, but I'm having trouble making the connection to an actual equation for "phi"...

 

As shown in the first post, there is a particular rotation that is used phi, theta, psi. Perhaps you would be kind enough to complete the formula based on the link provided?

 

Euler phi = atan(???).

 

Thanks!

 

 

0 Kudos
Message 3 of 15
(5,098 Views)

Hi 🙂

 

I believe it is:

 

phi=atan({-sin(phi)*cos(psi)}/cos(phi))

 

🙂 

Sam S
Applications Engineer
National Instruments
0 Kudos
Message 4 of 15
(5,090 Views)

Thanks again... but the equation for phi isn't a recursive function of itself - nor do you need to solve for 'psi' first in order to obtain the equation. The solution is some trig function of the 3x3 matrix of direction cosines. Based on that, what elements of the matrix are you attributing "sin(phi)*cos(psi)}/cos(phi)" from? From the link you provided, it appears you are referencing the matrix of (2,3) and (3,3) - of which is my proposed solution for phi; however, it is not giving me the same result when checked with the LabVIEW math function. Any other ideas?

 

As shown in the first post the equations will look something like this:

 

phi = atan((DCM(2,3))/(DCM(3,3))); %(This line is WRONG)

theta = acos(DCM(3,3));

psi = atan2(DCM(1,3),DCM(2,3));

 

I had attached a .vi in the first post that will allow you to test your solutions to the problem. Thanks for your help.

 

0 Kudos
Message 5 of 15
(5,084 Views)

Looking at the link provided the formula appears to be:

 

phi = atan2(DCM(3,1),-DCM(3,2))

 

You'll have to test.

0 Kudos
Message 6 of 15
(5,069 Views)

Hey all,

 

Darin you are close the answer is:

 

phi = atan((DCM(3,1))/(-DCM(3,2)))

 

🙂

 

I have tested it as well 🙂 

Sam S
Applications Engineer
National Instruments
0 Kudos
Message 7 of 15
(5,062 Views)

Wow... I was way off.

 

 

Much appreciated for your help!

0 Kudos
Message 8 of 15
(5,057 Views)

No problem 🙂

Sam S
Applications Engineer
National Instruments
0 Kudos
Message 9 of 15
(5,051 Views)

It is not immediately obvious to me that the two quadrant arctangent (atan) is sufficient, which is why I use the four quadrant arctangent (atan2). 

 

 

0 Kudos
Message 10 of 15
(5,048 Views)