From 771b197131f11777fcae7531b12e1486b5746527 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 25 Apr 2017 09:40:18 -0700 Subject: [PATCH] add option to calibrate individual fingers for the vr glove --- examples/pybullet/examples/hand.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/examples/pybullet/examples/hand.py b/examples/pybullet/examples/hand.py index 2c16cfe88..277e8ec79 100644 --- a/examples/pybullet/examples/hand.py +++ b/examples/pybullet/examples/hand.py @@ -22,8 +22,13 @@ hand=objects[0] #clamp in range 400-600 #minV = 400 #maxV = 600 -minV = 250 -maxV = 400 +minVarray = [275,280,350,290] +maxVarray = [450,550,500,400] + +pinkId = 0 +middleId = 1 +indexId = 2 +thumbId = 3 p.setRealTimeSimulation(1) @@ -33,7 +38,10 @@ def getSerialOrNone(portname): except: return None -def convertSensor(x): +def convertSensor(x, fingerIndex): + minV = minVarray[fingerIndex] + maxV = maxVarray[fingerIndex] + v = minV try: v = float(x) @@ -70,10 +78,10 @@ if (ser is not None and ser.isOpen()): line = str(ser.readline()) words = line.split(",") if (len(words)==6): - pink = convertSensor(words[1]) - middle = convertSensor(words[2]) - index = convertSensor(words[3]) - thumb = convertSensor(words[4]) + pink = convertSensor(words[1],pinkId) + middle = convertSensor(words[2],middleId) + index = convertSensor(words[3],indexId) + thumb = convertSensor(words[4],thumbId) p.setJointMotorControl2(hand,7,p.POSITION_CONTROL,pi/4.) p.setJointMotorControl2(hand,9,p.POSITION_CONTROL,thumb+pi/10)