forked from thefekete/robotarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample3.py
52 lines (44 loc) · 1.38 KB
/
example3.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
"""example3.py - complex usage of Al5x with SSC-32 connected on /dev/ttyUSB0.
This will continue to run through until the user hits ctrl-C.
"""
from robotarm.al5x import Al5x, AL5D
from robotarm.controllers import Ssc32
s = Ssc32('/dev/ttyUSB0')
s.trim(2, 0.025)
s.trim(3, -0.025)
r = Al5x(AL5D, servo_controller=s)
r.max_speed = 30
r.acceleration = 75
r.update_interval = 0.005
r.parked_state = dict(pos=[0, 8, 3], gripper_angle=0.0,
grip=0.0, wrist_rotate=0.0)
states = [
dict(pos=[3, 8, 1], gripper_angle=0,
wrist_rotate=-80),
dict(pos=[3, 8, 1], gripper_angle=0,
grip=0.28, wrist_rotate=-80),
{'pause': .5},
dict(pos=[3, 8, 6], gripper_angle=0,
wrist_rotate=-80),
dict(pos=[-3, 8, 6], gripper_angle=0,
wrist_rotate=80),
dict(pos=[-3, 8, 3], gripper_angle=0,
wrist_rotate=80),
dict(pos=[-3, 8, 3], gripper_angle=0,
grip=0.0, wrist_rotate=80),
{'pause': .5},
dict(pos=[-3, 8, 6], gripper_angle=0,
wrist_rotate=80),
dict(pos=[3, 8, 6], gripper_angle=0.0,
wrist_rotate=-80)]
try:
r.park()
while True:
raw_input("Press Enter to continue")
for i in states:
if 'pause' in i:
sleep(i['pause'])
else:
r.move(i)
except KeyboardInterrupt:
r.park()