LeapMotion

javadoc

This service will use the hand tracking capabilities of the Leap Motion device with the power of the SDK v2.

 

In order to get it working properly :

1) Install the LeapMotion Software from here : https://www.leapmotion.com/setup

2) Install the LeapMotion2 service from the MyRobotLab Runtime tab (just like you do with the other services ) MRL VERSION 1.0.95 or higher 

3)Enjoy the LeapMotion2.py example script

References:

Here is a script to test if your LeapMotion device is working properly with Myrobotlab

[[service/LeapMotion2.py]]

Here is another script to make the LeapMotion to track your fingers and to move InMoov fingers accordling 


#file : home/Alessandruino/LeapMotion2.fingerAngle.py edit raw
inmoov = Runtime.createAndStart("inmoov","InMoov")

inmoov.startRightHand("COM5")

inmoov.rightHand.index.setMinMax(30,89)
inmoov.rightHand.thumb.setMinMax(30,60)
inmoov.rightHand.majeure.setMinMax(30,89)
inmoov.rightHand.ringFinger.setMinMax(30,90)
inmoov.rightHand.pinky.setMinMax(30,90)

sleep(1)

inmoov.rightHand.startLeapTracking()

# inmoov.rightHand.stopLeapTracking()

 

Examples:


#file : service/LeapMotion.py edit raw
#####################################################
#
# this simple script will print in the python tab the grab strength 
# of your left hand
#
# LeapMotion finger types are defined
# as the following:
# Type.TYPE_THUMB 
# Type.TYPE_INDEX 
# Type.TYPE_MIDDLE
# Type.TYPE_RING 
# Type.TYPE_PINKY

from com.leapmotion.leap.Finger import Type
# from __future__ import division

leap = Runtime.createAndStart("leap","LeapMotion")

leap.addFrameListener(python)

def onFrame(frame):
 
 strength = ((frame.hands().leftmost().grabStrength())*100)
 print strength

leap.startTracking()

mryosoo's picture

Hey man! nice work on the

Hey man! nice work on the leap motion. I just want to ask. If i want to do it in a python script only with no myrobotlab, what will i modify with the code?

laia's picture

get angles leap motion

Hello,

how can I get the angles that the leap motion is setting to the servos? I can't find documentation of how the function inmoov.rightHand.startLeapTracking() works.

What I need is to do something like this:

inmoov.rightHand.index.write(leapmotionAngleIndex).
 
Thank you!
Alessandruino's picture

Hi.. try with this script and

Hi.. try with this script and let me know :


#file : /home/Alessandruino/leapBasic.py edit raw
leap = Runtime.start("leap","LeapMotion")

leap.addLeapDataListener(python)

def onLeapData(data):
  print (data.rightHand.index)

leap.startTracking()