09-02-2018 01:13 PM
Hello,
I am currently working on a project using leap motion controller where I need to calculate a certain angle using the function AngleTo() by import a c library in the labview program. I am trying to read the parameters of the function in a dll file using connectivity-->Library function node but then the message "Error 1097 occurred at Call Library Function Node" appears. The function is the one displayed below and it gets 2 parameters (Yaxis,Zaxis) and returns an angle. Has anyone had the same problem? Or can anyone propose me a better way of importing a dll file ?
Thank you in advance
09-02-2018 08:23 PM
It isn't clear to me why you are using a C library to calculate the angle between two vectors (unless you don't know any of the relevant math). You haven't shown us the LabVIEW code (VIs please, no pictures) so we don't know what you mean by a "vector" (2D? 3D? generalized?) nor how it is represented. Presumably LabVIEW comes in here, somewhere.
If the Vectors are 2D, and you are representing them as being from the Origin to the point (X, Y), either as an Array of 2 Dbls or as a Cluster of two Dbls, the simplest way to get the Angle Between is to switch from the Real X-Y plane to the Complex (Argand) plane, where the vector is represented by its length (r) and angle with the X axis (theta). "AngleTo" then becomes a simple subtraction problem, without even needing to convert to/from radians (unless, of course, you want the answer in degrees).
Bob Schor
09-03-2018 02:33 AM - edited 09-03-2018 02:34 AM
Dear Bob_Schor
Thank you for your quick reply,
Let me describe better the problem
I want to calculate the angle between the finger tips and the palm. And by angle i mean the realtive angle. For example when the whole hand is moving but the finger tips are not it must return 0 angle. What I did was to download the Leap Motion SDK V2 2.3.1 which has the method angleTo() and and makes it possible to get the angle between the pointables and the palm (this function is not contained in the makerhub leap toolkit). But i need to import the c library from which i can take this function.The angeTo() function can be found here: https://developer-archive.leapmotion.com/documentation/v2/cpp/api/Leap.Vector.html?proglang=cpp#cpps...
Below I attach the vi (Do not mind about the second while loop as i use it for some other measurements) and the dll file.
Thank you
09-03-2018 07:16 AM
What is your "model"? You talk about hand position and finger (tip?) position. If you are concerned with measuring angles, you probably want joint positions, such as wrist and elbow. Let's say you know Elbow(X, Y), Wrist(X, Y), and Fingertip (X, Y). You might define "Hand(X,Y)" as the midpoint between Wrist and Elbow (assuming the Fingers don't "wiggle" or have much lateral movement). Alternatively, if you don't have a Wrist sensor, but have a Hand and Fingertip sensor, you can compute Wrist by projecting the Finger-Hand vector a length back.
You need one stationary point to use as your Origin, e.g. Elbow. With this, you can calculate a Hand Vector and a Fingertip Vector, then do the AngleBetween calculation as I described previously. If you lack a stable Reference Frame, you don't have an Origin for defining angles (i.e. the point (0, 0) has no relationship to the body segments you are measuring).
I hope this is clear. If not, draw a picture of an isolated hand (without the forearm) and ask "How do I define the angular position of the hand"? The answer is "with respect to what?". You can define the orientation of the hand/fingertip by comparing the center of the hand with the end of the finger, but a hand without the rest of the body is just "waving in the wind". What you need is to know the relationship of the hand with the arm -- are they aligned, or is the hand rotated at the wrist? You need an additional reference point to answer that question.
Bob Schor
09-05-2018 03:16 AM
The method angleto() computes the desired angle for me. My problem is that when I import from LeapCSharp.dll the method angleto() as well as the methods yaxis() and zaxis() which are the two parameters of angleto() i get the error i described. And when i try to test the yaxis() and zaxis() method alone nothing seems to happen, the program runs with no error but at the return indicator is just displayed a sequence of numbers.
09-05-2018 06:48 AM
You are quite likely barking up the wrong tree here. The documentation you show in your first post very much looks like c# code definitions and they are usually not imported as a C DLL but as a .Net assembly. The Vector object is definitely nothing you can import through the Call Library Node, even if the DLL happens to export according C functions. It is an object managed by the according runtime library and only create-able and managable through that library. If it is really C it is in fact C++ and the Call Library Node has absolutely no provisions to interface to C++ functions in any way and does not support any kind of C++ objects.
The name of the DLL being LeapCSharp.dll really makes me believe that it is a .Net assembly (maybe with mixed mode code exporting also some kind of C++ functions). But importing anything but a .Net assembly in C# means having to go through unmanaged code and that is a pain in the ass and not something most people want to do nor are prepared to handle. So calling in the DLL name CSharp and not exporting a .Net interface would be at least highly misleading and in fact quite idiotic.
Try to place a .Net constructor on your diagram and point it at that DLL and see if the dialog shows any createable objects. If that doesn't give you anything, then try to place a .Net method node on your diagram and select Browse in the popup menu and point it again at this DLL. The second is necessary for static object classes as they do not have a constructor.