-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample_movements.py
77 lines (50 loc) · 2.05 KB
/
example_movements.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
#!/usr/bin/env python
import time
import signal
import sys
import rospy
import tf
import math
from ur_controller import URController
def exit_gracefully(signum, frame):
# restore the original signal handler as otherwise evil things will happen
# in raw_input when CTRL+C is pressed, and our signal handler is not re-entrant
signal.signal(signal.SIGINT, original_sigint)
try:
if raw_input("\nAre you sure you want to quit? (y/n)> ").lower().startswith('y'):
sys.exit(1)
except KeyboardInterrupt:
print("Ok ok, quitting")
sys.exit(1)
# restore the exit gracefully handler here
signal.signal(signal.SIGINT, exit_gracefully)
def run_main():
ur_controller = URController()
ur_controller.home_arm(10)
ee_pose = ur_controller.get_ee_pose()
## Move Forward 10 centimeters
new_ee_pose = [ee_pose[0], ee_pose[1]-0.1, ee_pose[2], ee_pose[3], ee_pose[4], ee_pose[5]]
ur_controller.move_ee(new_ee_pose, 5)
ee_pose = ur_controller.get_ee_pose()
## Move Down 10 centimeters
new_ee_pose = [ee_pose[0], ee_pose[1], ee_pose[2]-0.1, ee_pose[3], ee_pose[4], ee_pose[5]]
ur_controller.move_ee(new_ee_pose, 5)
ee_pose = ur_controller.get_ee_pose()
## Move Up 10 centimeters
new_ee_pose = [ee_pose[0], ee_pose[1], ee_pose[2]+0.1, ee_pose[3], ee_pose[4], ee_pose[5]]
ur_controller.move_ee(new_ee_pose, 5)
ee_pose = ur_controller.get_ee_pose()
## Move Backward 10 centimeters
new_ee_pose = [ee_pose[0], ee_pose[1]+0.1, ee_pose[2], ee_pose[3], ee_pose[4], ee_pose[5]]
ur_controller.move_ee(new_ee_pose, 5)
current_joints = ur_controller.get_joints()
current_joints[5] -= 90
## Rotate the last joint -90 degrees
ur_controller.move_joints_in_degrees(current_joints, 3)
current_joints[5] += 90
## Rotate the last joint +90 degrees
ur_controller.move_joints_in_degrees(current_joints, 3)
if __name__ == '__main__':
original_sigint = signal.getsignal(signal.SIGINT)
signal.signal(signal.SIGINT, exit_gracefully)
run_main()