Hello,
I got a leapmotion, i've installed the software from their website and tested it, it works. Then i installed the leapmotion2 service, and typed this script as explain in the leapmotion page :
#this simple script will print in the python tab the grab strength of your left hand
from
__future__
import
division
leap
=
Runtime.createAndStart(
"leap"
,
"LeapMotion2"
)
leap.addFrameListener(python)
def
onFrame(frame):
strength
=
((frame.hands().leftmost().grabStrength())
*
100
)
print
strength
leap.startTracking()
And i would get this error : 4982 [Thread-6] ERROR class org.myrobotlab.framework.Service - did not find method - onInit(Controller)
Then i checked the python tab and it was showing a number between 0 and 100 and i was wondering if it possible to get the fingers position or not ?
Thanks in advance
I'm not even sure if the SDK
I'm not even sure if the SDK is fully supported, i'm trying to do this
frame.hands().rightmost().fingers().is_empty and it says :
Ok to answer myself, i found
Ok to answer myself, i found out that the Java Leap DLL was used in MRL, and i was reading the Python API documentation. So if you wanna use LeapMotion with MRL, use the JAVA LeapMotion API documentation here :
https://developer.leapmotion.com/documentation/java/api/Leap_Classes.ht…
Correct its Java, but you can
Correct its Java, but you can access the Java methods "through" Python - but they will have the Java format of the method.
Did you get what you needed?
In MRL on a frame you should be able to do this method..
frame.hands().rightmost().fingers().isEmpty()
I can't identify the fingers
I can't identify the fingers in MRL, it's so weird i use this :
finger_list = frame.hands().get(0).fingers()
for finger in finger_list:
if finger.type() == TYPE_THUMB:
print "thumb"
but it says that it doesn't know TYPE_THUMB, so i tried Finger.TYPE_THUMB as there is an enum in the Finger class with TYPE_THUMB, TYPE_INDEX, etc..I don't understand this.
upper case usually stands for
upper case usually stands for constants - quick google search on TYPE_THUMB, LeapMotion gave me this link
https://developer.leapmotion.com/documentation/python/api/Leap.Finger.h…;
Below is snippet .. so in Python just have at the top
TYPE_THUMB = 0 etc. ..
then in your function you can have
def onFrame(frame):
global TYPE_THUMB, etc...
finger_list = frame.hands().get(0).fingers()
for finger in finger_list:
if finger.type() == TYPE_THUMB:
print "thumb"
New in version 2.0.
The integer code representing the finger name.
I know these are enums so
I know these are enums so instead, i tried using 0 1 2 3 4 but it doesn't go into the if code, its so strange.
"doesn't go into the if code"
"doesn't go into the if code" <- does this mean there is an Error returned?
No, anyway i've used the
No, anyway i've used the tools here : http://www.inmoov.fr/leap-motion-tuto/
And i manage to control the servos with leapmotion, however in order to get this working i have to upload StandardFirmata to arduino and i have an issue here. Is there a way to get StandardFirmata and the generated MRL code for arduino to coexist ? Because i want to get kinect and leapmotion working to control my InMoov.
I've sent a signal for help
I've sent a signal for help ...
So i took the javascript code
So i took the javascript code given in the Inmoov website to control hand with leapmotion, and tried to convert it to be usable in MRL, but i have an issue :
That javascript code expects to have 40 frames/s and not capture every frame like it is the case in MRL, so i wanna implement LeapMotion so that you can use both methods (The listener and the while version where you process as much frames as you want and not every frame whenever there is one) since i dont need to be as precise as onFrame function allows me to be (it causes a problem where my servo doesn't have enough time to move, but moves all direction too fast and gives me a weird result).
So my question here is how do i recompile (easily if possible) MRL if i wanted to (i want to modify the LeapMotion.java file) ?
TYPE_THUMB example leap motion
In python land, you've gotta import the java classes to they are known locally.
At the top of your script, you can add the following line:
Well it says that there is
Well it says that there is no module such as : com.leapmotion.leap.Finger.Type
jar file missing in the classpath?
Hmm.. That's strange. so when you do
"import com.leapmotion.leap.Finger.Type as Type" it no worky..
I wonder if the LeapJava.jar is in your classpath... Check if you have it in your libraries/jar directory... That's where it's defined..
I have that in the jar folder
I have that in the jar folder
java vs python syntax oops.. .
Sorry, my bad. The example I gave was some strange hybrid of java syntax and python syntax.
try
"from com.leapmotion.leap.Finger import Type"