From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Euler Angles to Directional Cosines in FPGA space

Solved!
Go to solution

Hey guys,

 

Relatively new LabVIEW user here. I am trying to implement some code that currently runs on an RT target and send it to an FPGA to do calculations.

 

Basically, we're running kinematics on RT (with inputs and calculations here) but I want to let the FPGA do the calculations because eventually I want to run the entire system on the FPGA. I was wondering how I could do this particular function in the FPGA space?

 

I have found how to do this function on a more fundamental basis (using inverse cosine and inverse tangent) but I am not sure how to run these complex mathematics on the FPGA side.

 

Does anyone have any ideas where I would even start?

 

Thanks heaps

0 Kudos
Message 1 of 8
(3,623 Views)

Wow.  Euler Angles describe the rotation of a rigid body in three-space about three mutually-perpendicular axes, either fixed in space or fixed to the object.  It also matters in which (axis) order you do the rotations, so it is a complex "mess" of conventions.

 

Direction Cosines, on the other hand, have nothing to do with rotations!  Consider a single line going through the origin of a 3-D Cartesian system.  Take the plane formed by this line and each of the three Axes -- the direction cosines are the cosines of the angle between the line and axis in the plane containing both of them.

 

It is very unclear to me how you possibly go from one to the other without a lot of additional information.

 

Bob Schor

0 Kudos
Message 2 of 8
(3,613 Views)

Hi Bob,

 

Ive attached two pictures illustrating what i mean. This function gives us the required transformation (rotation) matrix.

 

With 4x4 rotation matrices as you know there are the 3 main parts: the rotation (the first 3x3), the position (the RHS) and the bottom row (which is usually 0001)

 

In this VI, we have set parameters for joint lengths and we select the euler angle (the rotation axis we want), then we select the position we want (x,y,z) then we create the transformation matrix of these inputs (see second image)

 

When creating the transformation matrix we take the euler angle (axis we want) and put it into the euler angle to directional cosine function. This function places these into the correct form in the matrix ( Rx(theta) Ry(Theta0 and Rz(theta) ) form. then we just select the postion we want (in the middle of the block) and then we just add the last row (at the bottom of the block).

 

then we just combine the matrices and have our result (for example, Joint1)

 

I was just wondering if there is any way I could use or create the function in the FPGA space. I guess I could just define set matrices that can be selected using an enum and just add the angles into that before combining, but I thought I would ask if there was some way that someone may have used before or know of doing. 

 

Sorry if this sounds silly, and let me know if you guys want me to try and explain myself a bit better - I may have stepped over some important bits

 

Thanks!

 

Muri

Download All
0 Kudos
Message 3 of 8
(3,605 Views)

Hi,

 

I am trying to create transformation matrices in labview/fpga. I was wondering if it is possible to use trig functions (sin and cosine) in a labview matrix. I intend on taking an input theta and sending that to the matrix.

 

Or is the only way to have the calculations performed seperately then made into an array/matrix.

 

Thanks and soryr for the silly question

 

Muri

EDIT: I think the latter is probably the only way All good - thanks!

0 Kudos
Message 4 of 8
(3,604 Views)

Please, if you want help or suggestions about your LabVIEW VI, attach the VI, not a picture of the VI.  We can't use LabVIEW to help us examine a picture.  We can't rewire a picture.  We can't try to run a picture to see what happens (in order to understand what you are trying to do).

 

Bob Schor

0 Kudos
Message 5 of 8
(3,525 Views)

Hi Bob,

 

I seem to have overcomplicated my issue - I just completed the translations fundamentally instead which answered my questions.

 

Thank you for your replies (:

 

Muri.

0 Kudos
Message 6 of 8
(3,496 Views)

Great!  However, you posed this question on the Forum, and you have figured out an answer.  You would do the Community a service (as there are others who will want to know how to handle Rotation Matrices, Euler Angles, and Direction Cosines), so please consider writing up a "solution", if nothing more than a Word or LaTeX document showing the relevant Math involved and explaining (briefly) what you are doing.  You will help someone else.  You can also mark that Post (with the Solution) as the Solution, well-deserved.

 

Bob Schor

Message 7 of 8
(3,477 Views)
Solution
Accepted by topic author Muri777

Good idea, I will do a super quick write up here.

 

There are 3 rotation matrices, 1 for each 3 dimensional cartesian axis.

 

Using this function in the RT space provides us wth the correct results. However on the FPGA space, I went around the problem like this. Pretty simple but ive attached an image of the vi.

 

eauler_fundamentals.PNG

 

In this vi, we take an angle (remember that the FPGA uses pi*radians, meaning youll need to take pi out of the regular radians) as an input to the high throughput sine and cosine function. The output of the sine/cosine function is built into an array with the values 1, cos(θ), cos(θ), sin(θ), -sin(θ) in this order. 

 

The array up top correlates to the positions of trig functions and the number 1 (so that for the X case, the number 1 goes into the 3x3 matrix position 0, the cos(θ) goes into the 4th position in the matrix etc). This gets indexed for each axis (X,Y,Z) and built into a 1D array before being sent back to the RT.

 

And thats it really! Not that complex but having the original RT function in FPGA would have just made life easier haha.

Message 8 of 8
(3,451 Views)