-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhead_move.py
157 lines (122 loc) · 5.04 KB
/
head_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
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
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
import time
import almath
class Headmovement:
def __init__(self,ip):
try:
self.motionProxy = ALProxy("ALMotion", ip, 9559)
except Exception,e:
print "Could not create proxy to ALMotion"
print "Error was: ",e
sys.exit(1)
def movehead(self, pitch, yaw):
self.motionProxy.setStiffnesses("Head", 1.0)
self.motionProxy.setAngles("HeadPitch",int(pitch)*almath.TO_RAD,0.1)
self.motionProxy.setAngles("HeadYaw",int(yaw)*almath.TO_RAD,0.1)
time.sleep(2)
self.motionProxy.setStiffnesses("Head", 0.0)
return
def head_nod(self):
self.motionProxy.setStiffnesses("Head", 1.0)
self.motionProxy.setAngles("HeadYaw",0,0.15)
self.motionProxy.setAngles("HeadPitch",20.0*almath.TO_RAD,0.1)
time.sleep(0.5)
self.motionProxy.setAngles("HeadPitch",-20.0*almath.TO_RAD,0.1)
time.sleep(1.0)
self.motionProxy.setAngles("HeadPitch",20.0*almath.TO_RAD,0.1)
time.sleep(1.0)
self.motionProxy.setAngles("HeadPitch",-20.0*almath.TO_RAD,0.1)
time.sleep(1.0)
self.motionProxy.setAngles("HeadPitch",0,0.05)
time.sleep(1.0)
self.motionProxy.setStiffnesses("Head", 0.0)
return
def head_shake(self):
self.motionProxy.setStiffnesses("Head", 1.0)
self.motionProxy.setAngles("HeadPitch",10.0*almath.TO_RAD,0.05)
time.sleep(0.2)
self.motionProxy.setAngles("HeadYaw",-20.0*almath.TO_RAD,0.2)
time.sleep(0.4)
self.motionProxy.setAngles("HeadYaw",20.0*almath.TO_RAD,0.2)
time.sleep(0.4)
self.motionProxy.setAngles("HeadYaw",-20.0*almath.TO_RAD,0.2)
time.sleep(0.4)
self.motionProxy.setAngles("HeadYaw",0,0.15)
self.motionProxy.setAngles("HeadPitch",0,0.05)
time.sleep(0.8)
self.motionProxy.setStiffnesses("Head", 0.0)
return
def head_sweep(self):
self.motionProxy.setStiffnesses("Head", 1.0)
self.motionProxy.setAngles("HeadYaw",30.0*almath.TO_RAD,0.08)
self.motionProxy.setAngles("HeadPitch",10.0*almath.TO_RAD,0.05)
time.sleep(1.5)
self.motionProxy.setAngles("HeadYaw",-30.0*almath.TO_RAD,0.08)
time.sleep(2.5)
self.motionProxy.setAngles("HeadYaw",0,0.08)
self.motionProxy.setAngles("HeadPitch",0,0.05)
time.sleep(1.5)
self.motionProxy.setStiffnesses("Head", 0.0)
return
def head_sweep_1(self):
self.motionProxy.setStiffnesses("Head", 1.0)
self.motionProxy.setAngles("HeadYaw",30.0*almath.TO_RAD,0.08)
self.motionProxy.setAngles("HeadPitch",10.0*almath.TO_RAD,0.03)
time.sleep(2.0)
self.motionProxy.setAngles("HeadYaw",10.0*almath.TO_RAD,0.08)
self.motionProxy.setAngles("HeadPitch",15.0*almath.TO_RAD,0.03)
time.sleep(1.0)
self.motionProxy.setAngles("HeadYaw",-30.0*almath.TO_RAD,0.08)
time.sleep(2.5)
self.motionProxy.setAngles("HeadYaw",0,0.08)
self.motionProxy.setAngles("HeadPitch",0,0.05)
time.sleep(1.5)
self.motionProxy.setStiffnesses("Head", 0.0)
return
def head_sweep_2(self):
self.motionProxy.setStiffnesses("Head", 1.0)
self.motionProxy.setAngles("HeadYaw",30.0*almath.TO_RAD,0.08)
self.motionProxy.setAngles("HeadPitch",-10.0*almath.TO_RAD,0.03)
time.sleep(1.5)
self.motionProxy.setAngles("HeadYaw",-10.0*almath.TO_RAD,0.08)
self.motionProxy.setAngles("HeadPitch",-5.0*almath.TO_RAD,0.03)
time.sleep(2.0)
self.motionProxy.setAngles("HeadYaw",-20.0*almath.TO_RAD,0.08)
time.sleep(1.5)
self.motionProxy.setAngles("HeadYaw",0,0.08)
self.motionProxy.setAngles("HeadPitch",0,0.05)
time.sleep(1.5)
self.motionProxy.setStiffnesses("Head", 0.0)
return
def head_sweep_3(self):
self.motionProxy.setStiffnesses("Head", 1.0)
self.motionProxy.setAngles("HeadYaw",-10.0*almath.TO_RAD,0.08)
self.motionProxy.setAngles("HeadPitch",5.0*almath.TO_RAD,0.03)
time.sleep(1.5)
self.motionProxy.setAngles("HeadYaw",-15.0*almath.TO_RAD,0.08)
self.motionProxy.setAngles("HeadPitch",-5.0*almath.TO_RAD,0.03)
time.sleep(2.0)
self.motionProxy.setAngles("HeadYaw",10.0*almath.TO_RAD,0.08)
time.sleep(1.5)
self.motionProxy.setAngles("HeadYaw",0,0.08)
self.motionProxy.setAngles("HeadPitch",0,0.05)
time.sleep(1.5)
self.motionProxy.setStiffnesses("Head", 0.0)
return
if __name__ == "__main__":
robotIp = "127.0.0.1"
if len(sys.argv) <= 1:
print "Usage python head_move.py ip optional: pitch yaw"
else:
robotIp = sys.argv[1]
if len(sys.argv) <= 3:
robotIp = sys.argv[1]
else:
pitch = sys.argv[2]
yaw = sys.argv[3]
move = Headmovement(robotIp)
move.movehead(pitch,yaw)
#move.head_sweep()
#main(robotIp, pitch, yaw)