LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transformation problems, please look into my vi

I have been working on a 3d display of a force sensors.
The sensor will give the data of Fx, Fy and Fz, and i would like to display the resultant of the forces into a 3D display.
I formed two arrows to represent the resultant of the force working on the sensors.
So in my case i already have the arrow originally faced into a certain axis (i.e x axis).
I need to rotate it so it would looked correct according to the resultant of the 3 forces value.
If the original vector of the arrow would be [1 0 0]^T. and the result vector would be [Fx Fy Fz]^T.
i need to find a sets of angles (i.e. euler angles phi, theta and psy) to perform a set of rotations.
 
Here is the vi and some of the picture,
 
Another problem, why i can't set the initial rotation of the arrow (as seen on picture)
 
 
 
 
-Just a student-
0 Kudos
Message 1 of 5
(3,043 Views)
Sorry, I cannot run your VI because if missing data files.
 
Just looking at the code, part of your problem could be race conditions. You should look at your code very carefully!
 
In the attached code, the only reason you need the "first run?" check and case structure is the fact that you read from a local variable (RGBA) before the code has a chance to write to it. Since the control of the local variable is hidden, it can never be changed by the operator and since you write the same old constants to it 10 times per second does not make things any better. 😉 Why don't you eliminate the hidden control and wire things directly? If things remain constant, you can even bundle before the main loop.
 
Things that don't change don't need to be repeated over and over again. You need to define the background color only once and not 10 times per second. Much of your code belongs outside the while loop, because it needs to be done only once.
 
Let's look at the code in your picture:
You have all disconnected controls (1). You calculate theta1 and phi1 from two disconnected code segements (3), (6), and then read their value from local variables (7), (8). Since there is no data dependency between all these processes, they will occur in unpredictable order and is is very likely that you will read e.g. theta1 at (7) before the upper code has a chance to write a valid value to it. Why don't you use a wire between theta1 and the entry tunnel, eliminating the local variable? Now you have a data dependency and the case cannot start until it receives a valid theta from the calculation above. Similar arguments apply to many other sections of your code.
 
You need to use dataflow to ensure execution order! Currently you make typical mistakes that text programmers make when starting out with LabVIEW. For one perspective, see my old post here: http://forums.ni.com/ni/board/message?board.id=170&message.id=112401#M112401. Most likely, you can eliminate virtually all local variables.

Message Edited by altenbach on 07-17-2007 08:45 AM

Download All
0 Kudos
Message 2 of 5
(3,027 Views)
Data flow? is what you mean is using stacked sequence structure? to ensure the data flow.
i fixed a little, so the variable can be initially written.
 
 
i am attaching all the files now, so i hope you can look into it.
 
My real problem lies within the rotation problem.
My arrow is already face to one certain vector (i.e. [0 0 1]^T)
and then the resultant vector can be anything Fr = [Fx Fy Fz]^T
i need to do a set of rotations from 3 axis to get the first vector to the second.
 
and plus, if i use "set rotation" 3 times, all of the rotation is being resetted.
but if i use the "rotate object" i can't get the coordinate system rightly.
 
thank you soo much
-Just a student-
0 Kudos
Message 3 of 5
(2,996 Views)


@Nandha wrote:
Data flow? is what you mean is using stacked sequence structure? to ensure the data flow.

Noooooooo.....!!!!

Ensuring execution order with dataflow is to make sure that there is data dependency between successive nodes so they cannot execute out of order.

Dataflow  relies on two fundamental principles:

  1. A node cannot execute until ALL inputs have received data.
  2. Only once a node has finished, the outputs contain data.

I have no idea about the transformations etc. you are trying to do, but here is a near literal translation of your while loop. Notice that there is data dependency from the controls all the way to the subVIs.. Since they are wired in sequence, they can no longer execute out of order. Miraculously, we also no longer need any of the local variables. And we definitely don't need any sequences, stacked or otherwise. 😉

In a typical application, it is not worth to recalculate all this 10x per second. It is sufficient to do a recalculation only ff any of the relevant inputs changes its value. Easiest is an event structure.

You can run this and your old code in execution highlighting mode and you will see that the local variables in the loop get read before they get updated values from the upper disconnected code segments. You will also notice that your single frame case structure to the left is unecessary. No matter what, these statements will exeute before the while loop because there is data dependency.

You constantly break dataflow by using local variables instead of wires to communicate between code segments. For example look at the "camera controller in the opper part. You don't have ther terminal connected to anthing, but then immediately read from a local variable of the "camera controller". Why??? Just delete the local variable and hook the terminal up directly!

You should also make it a habit to wire the error cluster.

Message Edited by altenbach on 07-18-2007 12:26 AM

Message Edited by altenbach on 07-18-2007 12:28 AM

Message 4 of 5
(2,986 Views)

Darn, you are sooo good,

that explain why you are the veteran, thanks a million for the advice.
I think i will post another thread, to show the limitation of the labview in terms of 3D picture control.

I figure it out that the function the labview gives has some limitation that we can't break. (at least that what i thought).

Anyway thanks a lot for the advice, you help me a lot.Smiley Very Happy

-Just a student-
0 Kudos
Message 5 of 5
(2,969 Views)