02-17-2014 12:18 PM
Hi,
I have an array (max size 10) of xyz coordinates which i want to plot on a 3D graph.
These 10 points are constantly moving (data from a Leap Motion hand tracker)
I have attached a screen shot of simple VI and example data
How would i go about gaphing this?
02-17-2014 08:43 PM - edited 02-17-2014 08:44 PM
Hi coqwas,
That's a pretty interesting project you have there.
I guess there is 2 types of 3D graph which you can find (use quick drop if you have to): 3D Line Graph and Active X 3D Curve Graph. You can find some examples on 3D graphs in NI Example Finder as well (Open LabVIEW >> Help >> Find Examples... >> Search key word "3D graph").
Since it is a 3D array, can you tell me the array size for X, Y and Z (e.g. X size by Y size by Z size)? What does the row and column represents in the XYZ array shown inyour screenshot?
To use the 3D Line Graph.vi, you'll need to provide a 1D array of X vector, Y vector and Z vector. So you need to extract the values from that XYZ 3D array to those vectors respectively. You can extract the Z layers using Array Subset and Reshape array. Since I'm not really sure which part of the array (X, Y or Z) represents the finger no., you'll need to separate each array by individual fingers. Each XYZ array for each finger is fed to each create_plot_line.vi (4 fingers meaning 4 create_plot_line.vi) just as shown below:
You can see there is a number from 0-3 at the create_plot_line.vi. Those are the plot ID (0 means plot 0 and 1 means plot 1). What I am trying to do above is that I'm ploting 4 plots in 1 3D graph.
The plot ID is specified by going to the front panel >> Right click on the 3D Line Graph >> select 3D Graph Properties >> go to Plots tab >> on the left column called Plots, add as many plots you want to plot into the 3D graph.
Additional info:
http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/plotting_3d_graphs/
http://www.ni.com/white-paper/9388/en/
Warmest regards,
Lennard.C
02-18-2014 10:34 AM - edited 02-18-2014 10:36 AM
Another option is to use the 3D Picture Control directly. Please look at this shipping example (in LabVIEW 2013):
C:\Program Files (x86)\National Instruments\LabVIEW 2013\examples\Graphics and Sound\3D Picture Control\Creating Points and Lines.vi
This allows you to give a 'cloud' of 3D points and see in the graph:
02-18-2014 12:35 PM - edited 02-18-2014 12:52 PM
Hi Lennard, thanks! Such a useful reply, please stick with me 🙂
first your questions, and a better explanation,
So the rows are each finger, columns are x, y, z co-ordinates. [eg. finger 1 is at (2,180,51)]
the min:max sizes:
x: -100 : 100
y: 0 : 500
z: -100 : 100
So to plot the data like you suggested, I split the array into 5 separate arrays by row, to give each finger, then split each column to give separate x y z arrays.
I am using 'Array Index' blocks: (just finger 1 for now)
And this does seem to work, although it seems pretty laggy (might just be computer)
I guess I could carry out the array changes within the two For loops (per hand, per finger) so I'd need less array index blocks.
I will continue to try and get it all working.
One other point,
My overall goal is to have a shape (regular box, sphere, etc. at first; later 3D object from ASE, STL and VRML) displayed on the 3D graph and perform some action when the user's finger (xyz co-or) touches its boundary or is within the shape.
So my question is will I be able to load a shape onto this type of 3D graph? There seems to be a lot of different 'types' of graphs, if you get what I mean :-s
Thanks again!
02-18-2014 01:23 PM
Thanks Barp!
I think this might be exactly what im looking for!
I looked briefly at this example week ago but go stuck when trying to transform my data to fit the required type.
My data (as seen in the screenshots) is a 3D array of single numbers, how do I make it into an array of type 'Plot'?
Thanks!
02-18-2014 07:26 PM
Hi coqwas,
You're welcome. Well, you can repeat the Array Index functions for the other fingers and link them up like what i have recommended earlier.
As for your question: So my question is will I be able to load a shape onto this type of 3D graph? I have yet to try something like this but I guess you can try to create 3D Surface Graph (you can use quick drop to look for it) and connect the create_plot_surface.vi to the rest of the create_plot_line.vi like the screenshot I posted in my previous post. What you'll likely have is a surface object (let's say a ball) in the middle of the graph and your points of the finger.
I'm not sure what action you want that object to have when you touch its boundary but let's say if you want the ball to move, then I guess you'll need some additional programming to do the shifting of the coordinates and checking where it touches. Its sounds kind of interesting but I can only imagine it can be tedious as well.
As for your latest post on how to create 1D array of cluster of 3 elements, I think you might need to use a combination of shift registers and build arrays (if you want to plot out the past values as well)
Hope that helps
Warmest regards,
Lennard.C
02-18-2014 07:49 PM - edited 02-18-2014 07:49 PM
Thanks again Lennard
The action I plan to take when the uses touches the object, is activate 1 of 5 micro coin vibration motors I have embedded in a glove that is connected to an Arduino, connected to labview 🙂 I have the arduino side already up and running just need to complete the LabView side of things.
Thanks for your tip on the cluster of points.
And I will try the ball surface object as well
Thanks 🙂
coqwas
02-19-2014 11:31 AM
Yeah, you should try to obtain a datatype the better suite your application. In general the 3D matrix is hard to work with, so my suggestion is to transfer the data while you are generating. This kind of code leads to this block diagram. I used the Tunnel Mode >> Indexing on the fingers. And then, I used Tunnel Mode >> Concatenating on each change. This will show the point cloud of each finger on the 3D Graph.
Caviat: to define the 'cluster size' to be 3 points only, you have to right-click on the "Array to Cluster" and use Cluster size = 3.
If you do not have LabVIEW 2013, then the "concatenating" feature is not available and you have to use shift-register.
Hope this helps,
03-06-2014 10:37 AM
Hello
Using the Leap Motion controller have you created or used the controller for a 3 D Printer?
Thanks
Don1