06-17-2011 08:29 PM
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));
Solved! Go to Solution.
06-20-2011 10:34 AM
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
06-20-2011 11:09 AM
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!
06-20-2011 11:20 AM
Hi 🙂
I believe it is:
phi=atan({-sin(phi)*cos(psi)}/cos(phi))
🙂
06-20-2011 11:35 AM
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.
06-20-2011 12:50 PM
Looking at the link provided the formula appears to be:
phi = atan2(DCM(3,1),-DCM(3,2))
You'll have to test.
06-20-2011 12:55 PM
Hey all,
Darin you are close the answer is:
phi = atan((DCM(3,1))/(-DCM(3,2)))
🙂
I have tested it as well 🙂
06-20-2011 01:01 PM
Wow... I was way off.
Much appreciated for your help!
06-20-2011 01:12 PM
No problem 🙂
06-20-2011 01:23 PM
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).