-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharm_move.py
117 lines (86 loc) · 3.57 KB
/
arm_move.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
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
import time
import almath
class Armmovement:
def __init__(self,ip):
try:
self.motionProxy = ALProxy("ALMotion", ip, 9559)
self.postureProxy = ALProxy("ALRobotPosture", ip, 9559)
except Exception,e:
print "Could not create proxy to ALMotion"
print "Error was: ",e
sys.exit(1)
def movelarm(self, pitch, roll):
self.motionProxy.setStiffnesses("LArm", 1.0)
self.motionProxy.setStiffnesses("Head", 1.0)
self.motionProxy.setAngles("LShoulderPitch",int(pitch)*almath.TO_RAD,0.2)
self.motionProxy.setAngles("LElbowRoll",10*almath.TO_RAD,0.2)
self.motionProxy.setAngles("LShoulderRoll",int(roll)*almath.TO_RAD,0.2)
self.motionProxy.setAngles("HeadPitch",int(pitch)*almath.TO_RAD,0.1)
self.motionProxy.setAngles("HeadYaw",int(roll)*almath.TO_RAD,0.1)
self.motionProxy.openHand('LHand')
time.sleep(2)
self.motionProxy.closeHand('LHand')
self.postureProxy.goToPosture("Crouch", 0.5)
self.motionProxy.setStiffnesses("LArm", 0.0)
self.motionProxy.setStiffnesses("Head", 0.0)
return
def moverarm(self, pitch, roll):
self.motionProxy.setStiffnesses("RArm", 1.0)
self.motionProxy.setStiffnesses("Head", 1.0)
self.motionProxy.setAngles("RShoulderPitch",int(pitch)*almath.TO_RAD,0.2)
self.motionProxy.setAngles("RElbowRoll",10*almath.TO_RAD,0.2)
self.motionProxy.setAngles("RShoulderRoll",int(roll)*almath.TO_RAD,0.2)
self.motionProxy.setAngles("HeadPitch",int(pitch)*almath.TO_RAD,0.1)
self.motionProxy.setAngles("HeadYaw",int(roll)*almath.TO_RAD,0.1)
self.motionProxy.openHand('RHand')
time.sleep(2)
self.motionProxy.closeHand('RHand')
self.postureProxy.goToPosture("Crouch", 0.5)
self.motionProxy.setStiffnesses("RArm", 0.0)
self.motionProxy.setStiffnesses("Head", 0.0)
return
def arm_1(self):
self.motionProxy.setStiffnesses("RArm", 1.0)
self.motionProxy.setStiffnesses("LArm", 1.0)
self.motionProxy.setAngles("RShoulderRoll",-5*almath.TO_RAD,0.05)
time.sleep(0.5)
self.motionProxy.setAngles("LShoulderRoll",5*almath.TO_RAD,0.05)
time.sleep(0.5)
self.postureProxy.goToPosture("Crouch", 0.5)
self.motionProxy.setStiffnesses("RArm", 0.0)
self.motionProxy.setStiffnesses("LArm", 0.0)
return
def clasp(self):
self.motionProxy.setStiffnesses("RArm", 1.0)
self.motionProxy.setStiffnesses("LArm", 1.0)
self.motionProxy.openHand('LHand')
self.motionProxy.openHand('RHand')
time.sleep(1)
self.motionProxy.closeHand('LHand')
self.motionProxy.closeHand('RHand')
time.sleep(2)
self.postureProxy.goToPosture("Crouch", 0.5)
self.motionProxy.setStiffnesses("RArm", 0.0)
self.motionProxy.setStiffnesses("LArm", 0.0)
return
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python Larm_move.py IP LShoulderPitch LshoulderRoll"
else:
robotIp = sys.argv[1]
if len(sys.argv) <= 3:
robotIp = sys.argv[1]
else:
pitch = sys.argv[2]
roll = sys.argv[3]
inv = -int(roll)
move = Armmovement(robotIp)
move.clasp()
#move.arm_1()
move.movelarm(pitch, roll)
move.moverarm(pitch, inv)
#main(robotIp, pitch, roll)