Hardware: One arduino mega, Activator, servo HV2060MG powered with 7.2V

Software: Last MRL, not InMoov services.

https://youtu.be/MUemCpL0VyI

 

kwatters

7 years 6 months ago

Great Job!  That's fantastic.  How are you maping the movements to the servo angles?  Are you using inverse kinematics, or some other mapping functions?  

Would love to see the code, did you do this in python?

dom14

7 years 6 months ago

In reply to by kwatters

Hi, yes in python with openni service.

# -- coding: utf-8 --
# ##############################################################################
# Service kinect
# ##############################################################################
DEBUG_KINECT=0
isKinectActivated=1
 
KinectStarted=False
copyGestureIsOk=False
handTrackingIsOk=False
 
if isKinectActivated==1:
openni = Runtime.createAndStart("Kinect", "OpenNi")
python.subscribe(openni.getName(),"publishOpenNIData")
 
# ##############################################################################
#
# ##############################################################################
def copyGesture(b):
global KinectStarted
global enableMoveHeadRandom
global copyGestureIsOk
 
if isKinectActivated==1:
 
if b==True and KinectStarted==0:
# Position de repos
initialPosition()
 
enableMoveHeadRandom=False
talk("je te copie")
sleep(2)
 
armAttach("left")
armAttach("right")
armFullSpeed("left")
armFullSpeed("right")
 
openni.skeleton.leftElbow.mapXY(0, 180, 180, 0)
openni.skeleton.rightElbow.mapXY(0, 180, 180, 0);
openni.skeleton.leftShoulder.mapYZ(0, 180, 180, 0)
openni.skeleton.rightShoulder.mapYZ(0, 180, 180, 0);
 
openni.startUserTracking()
copyGestureIsOk=True
 
elif b==False and KinectStarted==1:
openni.stopCapture()
talk("j'arrête de te copier")
sleep(4)
initialPosition()
MoveEyesTimer.startClock()
KinectStarted=0
enableMoveHeadRandom=1
copyGestureIsOk=False
 
# ##############################################################################
#
# ##############################################################################
def onOpenNIData(data):
global skeleton
global KinectStarted
global enableMoveHeadRandom
 
if data and not KinectStarted:
KinectStarted = 1
enableMoveHeadRandom = False
talk("Acquisition des données")
# Stop les evenements aleatoires
VieAleatoire.stopClock()
 
if data and copyGestureIsOk:
skeleton = data.skeleton
 
leftElbow = round(skeleton.leftElbow.getAngleXY())
leftOmoplate = round(skeleton.leftShoulder.getAngleXY() * 1.1)
leftShoulder = round(skeleton.leftShoulder.getAngleYZ())
 
rightElbow = round(skeleton.rightElbow.getAngleXY())
rightOmoplate = round(skeleton.rightShoulder.getAngleXY() * 1.1)
rightShoulder = round(skeleton.rightShoulder.getAngleYZ())
 
try:
leftElbow = int(leftElbow)
leftOmoplate = int(leftOmoplate)
leftShoulder = int(leftShoulder) - 50
 
rightElbow = int(rightElbow)
rightOmoplate = int(rightOmoplate)
rightShoulder = int(rightShoulder) - 50
except ValueError:
print "Erreur de conversion: ", ValueError
 
if leftElbow>0 and leftOmoplate>0 and leftShoulder>0:
if DEBUG_KINECT==1:
print "Coude gauche   : ", leftElbow
print "Omoplate gauche: ", leftOmoplate
print "Epaule gauche  : ", leftShoulder
 
moveArm("left", leftElbow, 90, leftShoulder, leftOmoplate)
 
if rightElbow>0 and rightOmoplate>0 and rightShoulder>0:
if DEBUG_KINECT==1:
print "Coude droit    : ", rightElbow
print "Omoplate droite: ", rightOmoplate
print "Epaule droite  : ", rightShoulder
 
moveArm("right", rightElbow, 90, rightShoulder, rightOmoplate)
 

 

GroG

7 years 6 months ago

In reply to by kwatters

Great Work Dom !

Well done.

Its exciting to see someone work on a similar thing with a different approach !

Cheers !

A good thing indeed!

Have you thought about generating gesture files from the movements and make them repeatable? Also including speed and pauses?

Would be much nicer than the manual way of having to define each of the servo positions.

Problem running the script

hi, made only some language adjustions to your script and tried to run it.

I do not get the skeleton information with your script.

If I manually start capturing from the openni tab in the gui I do get the skeleton blended in but with the script I do not get the "onOpenNIData" function being called.

Any hint?