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:
@@ -10,6 +10,10 @@ int sensorPin3 = A3;
|
|||||||
void setup() {
|
void setup() {
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
digitalWrite(A0, INPUT_PULLUP);
|
||||||
|
digitalWrite(A1, INPUT_PULLUP);
|
||||||
|
digitalWrite(A2, INPUT_PULLUP);
|
||||||
|
digitalWrite(A3, INPUT_PULLUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ hand=objects[0]
|
|||||||
#minV = 400
|
#minV = 400
|
||||||
#maxV = 600
|
#maxV = 600
|
||||||
minV = 250
|
minV = 250
|
||||||
maxV = 450
|
maxV = 400
|
||||||
|
|
||||||
p.setRealTimeSimulation(1)
|
p.setRealTimeSimulation(1)
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ def convertSensor(x):
|
|||||||
if (v>maxV):
|
if (v>maxV):
|
||||||
v=maxV
|
v=maxV
|
||||||
b = (v-minV)/float(maxV-minV)
|
b = (v-minV)/float(maxV-minV)
|
||||||
return (1.0-b)
|
return (b)
|
||||||
|
|
||||||
ser = None
|
ser = None
|
||||||
portindex = 0
|
portindex = 0
|
||||||
@@ -62,6 +62,7 @@ while (ser is None and portindex < 30):
|
|||||||
|
|
||||||
if (ser is None):
|
if (ser is None):
|
||||||
ser = serial.Serial(port = "/dev/cu.usbmodem1421",baudrate=115200,parity=serial.PARITY_ODD,stopbits=serial.STOPBITS_TWO,bytesize=serial.SEVENBITS)
|
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()):
|
if (ser is not None and ser.isOpen()):
|
||||||
while True:
|
while True:
|
||||||
@@ -69,13 +70,13 @@ 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):
|
||||||
middle = convertSensor(words[1])
|
pink = convertSensor(words[1])
|
||||||
pink = convertSensor(words[2])
|
middle = convertSensor(words[2])
|
||||||
index = convertSensor(words[3])
|
index = convertSensor(words[3])
|
||||||
thumb = convertSensor(words[4])
|
thumb = convertSensor(words[4])
|
||||||
|
|
||||||
p.setJointMotorControl2(hand,7,p.POSITION_CONTROL,thumb)
|
p.setJointMotorControl2(hand,7,p.POSITION_CONTROL,pi/4.)
|
||||||
p.setJointMotorControl2(hand,9,p.POSITION_CONTROL,thumb)
|
p.setJointMotorControl2(hand,9,p.POSITION_CONTROL,thumb+pi/10)
|
||||||
p.setJointMotorControl2(hand,11,p.POSITION_CONTROL,thumb)
|
p.setJointMotorControl2(hand,11,p.POSITION_CONTROL,thumb)
|
||||||
p.setJointMotorControl2(hand,13,p.POSITION_CONTROL,thumb)
|
p.setJointMotorControl2(hand,13,p.POSITION_CONTROL,thumb)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user