add option to calibrate individual fingers for the vr glove
This commit is contained in:
@@ -22,8 +22,13 @@ hand=objects[0]
|
|||||||
#clamp in range 400-600
|
#clamp in range 400-600
|
||||||
#minV = 400
|
#minV = 400
|
||||||
#maxV = 600
|
#maxV = 600
|
||||||
minV = 250
|
minVarray = [275,280,350,290]
|
||||||
maxV = 400
|
maxVarray = [450,550,500,400]
|
||||||
|
|
||||||
|
pinkId = 0
|
||||||
|
middleId = 1
|
||||||
|
indexId = 2
|
||||||
|
thumbId = 3
|
||||||
|
|
||||||
p.setRealTimeSimulation(1)
|
p.setRealTimeSimulation(1)
|
||||||
|
|
||||||
@@ -33,7 +38,10 @@ def getSerialOrNone(portname):
|
|||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def convertSensor(x):
|
def convertSensor(x, fingerIndex):
|
||||||
|
minV = minVarray[fingerIndex]
|
||||||
|
maxV = maxVarray[fingerIndex]
|
||||||
|
|
||||||
v = minV
|
v = minV
|
||||||
try:
|
try:
|
||||||
v = float(x)
|
v = float(x)
|
||||||
@@ -70,10 +78,10 @@ if (ser is not None and ser.isOpen()):
|
|||||||
line = str(ser.readline())
|
line = str(ser.readline())
|
||||||
words = line.split(",")
|
words = line.split(",")
|
||||||
if (len(words)==6):
|
if (len(words)==6):
|
||||||
pink = convertSensor(words[1])
|
pink = convertSensor(words[1],pinkId)
|
||||||
middle = convertSensor(words[2])
|
middle = convertSensor(words[2],middleId)
|
||||||
index = convertSensor(words[3])
|
index = convertSensor(words[3],indexId)
|
||||||
thumb = convertSensor(words[4])
|
thumb = convertSensor(words[4],thumbId)
|
||||||
|
|
||||||
p.setJointMotorControl2(hand,7,p.POSITION_CONTROL,pi/4.)
|
p.setJointMotorControl2(hand,7,p.POSITION_CONTROL,pi/4.)
|
||||||
p.setJointMotorControl2(hand,9,p.POSITION_CONTROL,thumb+pi/10)
|
p.setJointMotorControl2(hand,9,p.POSITION_CONTROL,thumb+pi/10)
|
||||||
|
|||||||
Reference in New Issue
Block a user