-
Notifications
You must be signed in to change notification settings - Fork 0
/
controlMano.py
170 lines (141 loc) · 3.41 KB
/
controlMano.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# -*- coding: utf-8 -*-
import time as t
from Dedo import *
def testMano(tensionA,tensionC):
dbc = 0.1
pulgar.enable()
t.sleep(dbc)
indice.enable()
t.sleep(dbc)
medio.enable()
t.sleep(dbc)
indice.open()
t.sleep(dbc)
pulgar.open()
t.sleep(dbc)
medio.open()
t.sleep(5)
medio.closeControlado(tensionC)
t.sleep(1)
indice.closeControlado(tensionC)
t.sleep(1)
pulgar.closeControlado(tensionC)
t.sleep(1)
medio.apretar(tensionA)
t.sleep(dbc)
indice.apretar(tensionA)
t.sleep(dbc)
pulgar.apretar(tensionA)
t.sleep(15)
pulgar.open()
t.sleep(dbc)
indice.open()
t.sleep(dbc)
medio.open()
t.sleep(5)
pulgar.relax()
t.sleep(dbc)
indice.relax()
t.sleep(dbc)
medio.relax()
t.sleep(10)
pulgar.disable()
t.sleep(dbc)
indice.disable()
t.sleep(dbc)
medio.disable()
def testPinza(tensionA,tensionC):
dbc = 0.01
pulgar.enable()
t.sleep(dbc)
indice.enable()
t.sleep(dbc)
medio.enable()
t.sleep(dbc)
indice.open()
t.sleep(dbc)
pulgar.open()
t.sleep(dbc)
#medio.open()
t.sleep(5)
t.sleep(1)
pulgar.closeControlado(int(tensionC))
t.sleep(dbc)
indice.closeControlado(int(tensionC))
t.sleep(1)
indice.apretar(tensionA)
t.sleep(dbc)
pulgar.apretar(tensionA)
t.sleep(10)
pulgar.open()
t.sleep(dbc)
indice.open()
#t.sleep(dbc)
#medio.open()
t.sleep(5)
pulgar.relax()
t.sleep(dbc)
indice.relax()
#t.sleep(dbc)
#medio.relax()
t.sleep(10)
pulgar.disable()
t.sleep(dbc)
indice.disable()
t.sleep(dbc)
medio.disable()
def testSweep(tension):
indice.enable()
t.sleep(0.1)
indice.open()
t.sleep(5)
indice.sweep(tension)
#indice.close()
t.sleep(5)
indice.open()
t.sleep(5)
indice.relax()
t.sleep(5)
indice.disable()
def testDedo(tension_apriete,tension_controlado):
indice.enable()
t.sleep(0.1)
indice.open()
t.sleep(5)
indice.closeControlado(tension_controlado)
indice.apretar(tension_apriete)
#indice.close()
t.sleep(10)
indice.open()
t.sleep(5)
indice.relax()
t.sleep(5)
indice.disable()
def refTension(tension):
# convierte la referencia de tension en gramos a un valor en 8bits [0-255]
K = 0.011159057404310219
return int(tension / K / 1000)
if __name__ == '__main__':
mano_ser = ManoSerial('/dev/ttyACM0',500000)
# SS1 40
# SS2 53
# SS3 38
indice = Dedo(mano_ser, ss=TO_SS3, name="INDICE", max_mf=90, max_me=100)
pulgar = Dedo(mano_ser, ss=TO_SS2, name="PULGAR", max_mf=80, max_me=85)
medio = Dedo(mano_ser, ss=TO_SS1, name="MEDIO", max_mf=90, max_me=10)
mano_ser.startProcess()
t.sleep(1)
# maxima tension 2846
tendon_tens = 1000
tapriete = refTension(tendon_tens)
tcontrol = refTension(1000)
print("tension tendon: " + str(tendon_tens) + "g -> " + str(tapriete) + " valor de bits")
try:
#testPinza(tapriete,tcontrol)
testDedo(tapriete,tcontrol)
#testMano(tapriete,tcontrol)
#testSweep(tref)
mano_ser.stopProcess()
except Exception as e:
print(e)
mano_ser.stopProcess()