change hand.ino/py to match hardware changes (use pullup resistor, connect to gnd, instead of 5V + pull down resistor)

This commit is contained in:
Erwin Coumans 2017-04-24 09:56:27 -07:00
parent e8c1602232
commit d41a2fdfd4
2 changed files with 12 additions and 7 deletions

View File

@ -10,6 +10,10 @@ int sensorPin3 = A3;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
digitalWrite(A0, INPUT_PULLUP);
digitalWrite(A1, INPUT_PULLUP);
digitalWrite(A2, INPUT_PULLUP);
digitalWrite(A3, INPUT_PULLUP);
}
void loop() {

View File

@ -23,7 +23,7 @@ hand=objects[0]
#minV = 400
#maxV = 600
minV = 250
maxV = 450
maxV = 400
p.setRealTimeSimulation(1)
@ -44,7 +44,7 @@ def convertSensor(x):
if (v>maxV):
v=maxV
b = (v-minV)/float(maxV-minV)
return (1.0-b)
return (b)
ser = None
portindex = 0
@ -62,6 +62,7 @@ while (ser is None and portindex < 30):
if (ser is None):
ser = serial.Serial(port = "/dev/cu.usbmodem1421",baudrate=115200,parity=serial.PARITY_ODD,stopbits=serial.STOPBITS_TWO,bytesize=serial.SEVENBITS)
pi=3.141592
if (ser is not None and ser.isOpen()):
while True:
@ -69,13 +70,13 @@ if (ser is not None and ser.isOpen()):
line = str(ser.readline())
words = line.split(",")
if (len(words)==6):
middle = convertSensor(words[1])
pink = convertSensor(words[2])
pink = convertSensor(words[1])
middle = convertSensor(words[2])
index = convertSensor(words[3])
thumb = convertSensor(words[4])
p.setJointMotorControl2(hand,7,p.POSITION_CONTROL,thumb)
p.setJointMotorControl2(hand,9,p.POSITION_CONTROL,thumb)
p.setJointMotorControl2(hand,7,p.POSITION_CONTROL,pi/4.)
p.setJointMotorControl2(hand,9,p.POSITION_CONTROL,thumb+pi/10)
p.setJointMotorControl2(hand,11,p.POSITION_CONTROL,thumb)
p.setJointMotorControl2(hand,13,p.POSITION_CONTROL,thumb)