forked from jesnk/pepper_demo_gulliver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransition.py
351 lines (299 loc) · 17.7 KB
/
transition.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
import time
from naoqi import ALProxy
from data_list import *
from cameras import take_photo
from functions import updown, saju
from functions.play_music import *
from motion import photo_motion
aas_configuration = {"bodyLanguageMode": "contextual"}
class Transition:
def __init__(self):
pass
def get_html_address(self, file_name):
name = file_name
if len(name) > 5 and name[-5:] == '.html':
name = name[:-5]
return "http://198.18.0.1/apps/bi-html/" + name + '.html'
def home(self, srv, input_ret):
if input_ret['type'] == 'touch':
if input_ret['touch_position'] == 'BUTTON_MIDDLE_DOWN':
next_scene = 'first_menu'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['tts'].say("next menu")
return SCENES[next_scene]
elif input_ret['type'] == 'speech':
if input_ret['word'] == 'hello':
next_scene = 'first_menu'
srv['aas'].say("Hello, Nice to meet you!", aas_configuration)
srv['tablet'].showWebview(self.get_html_address(next_scene))
return SCENES[next_scene]
elif input_ret['word'] == 'pepper':
next_scene = 'home'
srv['aas'].say("Yep! Hello?!", aas_configuration)
return SCENES[next_scene]
elif input_ret['word'] == 'cheese':
# srv['tts'].say("Say cheese")
photo_test = take_photo.Photo(srv)
photo_test.take()
next_scene = 'photo_screen'
srv['tablet'].showWebview(self.get_html_address(next_scene))
time.sleep(3)
srv['tablet'].showWebview(self.get_html_address('home'))
pass
# default value
# return SCENES['home']
def first(self, srv, input_ret):
if input_ret['type'] == 'touch':
if input_ret['touch_position'] == 'BUTTON_LEFT':
next_scene = 'tour'
srv['tablet'].showWebview(self.get_html_address(next_scene))
#srv['tts'].say("next menu")
srv['aas'].say("What would you like me to introduce?")
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_RIGHT':
next_scene = 'entertain'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['tts'].say("next menu")
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_MIDDLE_DOWN':
next_scene = 'home'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say("To the initial screen")
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_RIGHT_DOWN':
next_scene = 'first_menu'
srv['tts'].setParameter("defaultVoiceSpeed", 100)
srv['aas'].say(
"Are you curious about me? I am Pepper. It is a humanoid robot made by Softbank, and can use artificial intelligence. It is characterized by a cute appearance, and is introduced in various fields such as finance, bookstore, medical care, and distribution fields in Korea")
srv['tts'].setParameter("defaultVoiceSpeed", 70)
return SCENES[next_scene]
elif input_ret['type'] == 'speech':
say = None
if input_ret['word'] == 'back':
next_scene = 'home'
elif input_ret['word'] == 'who':
next_scene = 'first_menu'
elif input_ret['word'] == 'tour':
next_scene = 'tour'
say = "What would you like me to introduce?"
elif input_ret['word'] == 'play':
next_scene = 'entertain'
say = "What should we do? Please choose one"
else:
next_scene = 'first_menu'
srv['tablet'].showWebview(self.get_html_address(next_scene))
if say is not None:
srv['aas'].say(say)
return SCENES[next_scene]
def tour(self, srv, input_ret):
if input_ret['type'] == 'touch':
if input_ret['touch_position'] == 'BUTTON_RIGHT':
next_scene = 'tour_hsr1'
srv['tts'].setParameter("defaultVoiceSpeed", 100)
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say("Let me explain the robots in our lab. First, HSR, a human helper robot, is a mobile operation robot.", aas_configuration)
next_scene = 'tour_hsr2'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say("It is about 1 meter tall and is a versatile robot that can recognize objects through various cameras and pick them up with a gripper. But is it ugly than me?",
aas_configuration)
next_scene = 'tour_blitz'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"The next robot, Blitz. It is a robot made by combining a base robot, which is specialized in moving objects, and a UR5 robot that picks up objects. In addition, it is a mobile operation robot that is equipped with sound and camera sensors, capable of recognizing objects and gripping them with a gripper.",
aas_configuration)
next_scene = 'tour_pepper1'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"The last robot to be introduced is me, Pepper. I am a humanoid robot made by Softbank, and I can use artificial intelligence.", aas_configuration)
next_scene = 'tour_pepper2'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"I have a cute appearance, and has been introduced in various fields such as finance, bookstores, medical care, and distribution fields in Korea. In addition, it is used as a standard robot in S, S, P, L, among the world robot competitions, Robo Cup League.",
aas_configuration)
srv['tts'].setParameter("defaultVoiceSpeed", 70)
next_scene = 'tour'
srv['tablet'].showWebview(self.get_html_address(next_scene))
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_LEFT':
next_scene = 'tour_ourlab1'
srv['tts'].setParameter("defaultVoiceSpeed", 100)
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"Let me introduce our lab. Our bio-intelligence lab is conducting the following studies. First, we are conducting interdisciplinary research in various fields such as artificial intelligence, psychology, and cognitive science to develop human-level artificial intelligence such as Baby Mind and VTT. We are also actively conducting research on robots on various platforms, such as home robots that work with humans and Robocup, a world robot competition.",
aas_configuration)
next_scene = 'tour_ourlab2'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say("If you have any other questions or inquiries, please refer to the following website or contact us.", aas_configuration)
srv['tts'].setParameter("defaultVoiceSpeed", 70)
next_scene = 'tour'
srv['tablet'].showWebview(self.get_html_address(next_scene))
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_MIDDLE_DOWN':
next_scene = 'home'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say("To the initial screen", aas_configuration)
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_LEFT_DOWN':
next_scene = 'first_menu'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['tts'].say("previous menu")
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_RIGHT_DOWN':
next_scene = 'tour'
srv['tts'].setParameter("defaultVoiceSpeed", 110)
srv['aas'].say(
"Are you curious about me? I am Pepper. It is a humanoid robot made by Softbank, and can use artificial intelligence. It is characterized by a cute appearance, and is introduced in various fields such as finance, bookstore, medical care, and distribution fields in Korea",
aas_configuration)
srv['tts'].setParameter("defaultVoiceSpeed", 70)
return SCENES[next_scene]
elif input_ret['type'] == 'speech':
if input_ret['word'] == 'robot':
next_scene = 'tour_hsr1'
srv['tts'].setParameter("defaultVoiceSpeed", 100)
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"Let me explain the robots in our lab. First, HSR, a human helper robot, is a mobile operation robot.",
aas_configuration)
next_scene = 'tour_hsr2'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"It is about 1 meter tall and is a versatile robot that can recognize objects through various cameras and pick them up with a gripper. But is it ugly than me?",
aas_configuration)
next_scene = 'tour_blitz'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"The next robot, Blitz. It is a robot made by combining a base robot, which is specialized in moving objects, and a UR5 robot that picks up objects. In addition, it is a mobile operation robot that is equipped with sound and camera sensors, capable of recognizing objects and gripping them with a gripper.",
aas_configuration)
next_scene = 'tour_pepper1'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"The last robot to be introduced is me, Pepper. I am a humanoid robot made by Softbank, and I can use artificial intelligence.",
aas_configuration)
next_scene = 'tour_pepper2'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"I have a cute appearance, and has been introduced in various fields such as finance, bookstores, medical care, and distribution fields in Korea. In addition, it is used as a standard robot in S, S, P, L, among the world robot competitions, Robo Cup League.",
aas_configuration)
srv['tts'].setParameter("defaultVoiceSpeed", 70)
next_scene = 'tour'
srv['tablet'].showWebview(self.get_html_address(next_scene))
return SCENES[next_scene]
elif input_ret['word'] == 'lab':
next_scene = 'tour_ourlab1'
srv['tts'].setParameter("defaultVoiceSpeed", 100)
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"Let me introduce our lab. Our bio-intelligence lab is conducting the following studies. First, we are conducting interdisciplinary research in various fields such as artificial intelligence, psychology, and cognitive science to develop human-level artificial intelligence such as Baby Mind and VTT. We are also actively conducting research on robots on various platforms, such as home robots that work with humans and Robocup, a world robot competition.",
aas_configuration)
next_scene = 'tour_ourlab2'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say(
"If you have any other questions or inquiries, please refer to the following website or contact us.",
aas_configuration)
srv['tts'].setParameter("defaultVoiceSpeed", 70)
next_scene = 'tour'
srv['tablet'].showWebview(self.get_html_address(next_scene))
return SCENES[next_scene]
elif input_ret['word'] == 'back':
next_scene = 'first_menu'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say("Okay. What should we do then?")
return SCENES[next_scene]
def entertain(self, srv, input_ret):
if input_ret['type'] == 'touch':
if input_ret['touch_position'] == 'BUTTON_MIDDLE_DOWN':
next_scene = 'home'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['tts'].say("To the initial screen")
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_LEFT_DOWN':
next_scene = 'first_menu'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['tts'].say("previous menu")
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_LEFT':
file_path = "/opt/aldebaran/www/apps/bi-sound/elephant.ogg"
# srv['tts'].post.say('yes')
player = ALProxy("ALAudioPlayer", PEPPER_IP, 9559)
player.post.playFileFromPosition(file_path, 0)
entertain.elephant(srv)
player.post.stopAll()
pass
elif input_ret['touch_position'] == 'BUTTON_RIGHT':
file_path = "/opt/aldebaran/www/apps/bi-sound/UrbanStreet.mp3"
# player = Dance(srv, "disco", PEPPER_IP)
# player.motion()
# print("hello")
player = ALProxy("ALAudioPlayer", PEPPER_IP, 9559)
player.post.playFileFromPosition(file_path, 0)
entertain.disco(srv)
player.post.stopAll()
photo_motion.stand(srv)
pass
elif input_ret['touch_position'] == 'BUTTON_RIGHT_DOWN':
next_scene = 'entertain2'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['tts'].say("next menu")
return SCENES[next_scene]
elif input_ret['type'] == 'speech':
if input_ret['word'] == 'elephant':
file_path = "/opt/aldebaran/www/apps/bi-sound/elephant.ogg"
# srv['tts'].post.say('yes')
player = ALProxy("ALAudioPlayer", PEPPER_IP, 9559)
player.post.playFileFromPosition(file_path, 0)
entertain.elephant(srv)
player.post.stopAll()
pass
elif input_ret['word'] == 'dance':
file_path = "/opt/aldebaran/www/apps/bi-sound/UrbanStreet.mp3"
# player = Dance(srv, "disco", PEPPER_IP)
# player.motion()
# print("hello")
player = ALProxy("ALAudioPlayer", PEPPER_IP, 9559)
player.post.playFileFromPosition(file_path, 0)
entertain.disco(srv)
player.post.stopAll()
photo_motion.stand(srv)
pass
elif input_ret['word'] == 'back':
next_scene = 'first_menu'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['aas'].say("Okay. What should we do then?")
return SCENES[next_scene]
def entertain2(self, srv, input_ret):
if input_ret['type'] == 'touch':
if input_ret['touch_position'] == 'BUTTON_MIDDLE_DOWN':
next_scene = 'home'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['tts'].say("To the initial screen")
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_LEFT_DOWN':
next_scene = 'first_menu'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['tts'].say("previous menu")
return SCENES[next_scene]
elif input_ret['touch_position'] == 'BUTTON_LEFT':
srv['aas'].say("Please tell me your date of birth in English.", aas_configuration)
text = saju.main(srv)
srv['aas'].say(text, aas_configuration) # written as "srv['ass']" before
elif input_ret['touch_position'] == 'BUTTON_RIGHT':
srv['tts'].say("You must say the number in English. Other language is not allowed.")
time.sleep(3) # wait for 3 seconds
updown.UpDown(srv).play()
elif input_ret['touch_position'] == 'BUTTON_RIGHT_DOWN':
next_scene = 'entertain'
srv['tablet'].showWebview(self.get_html_address(next_scene))
srv['tts'].say("next menu")
return SCENES[next_scene]
# return the object of the next scene
def switch(self, srv, scene, input_ret):
if scene == "home":
return self.home(srv, input_ret)
elif scene == "first_menu":
return self.first(srv, input_ret)
elif scene == "tour":
return self.tour(srv, input_ret)
elif scene == "entertain":
return self.entertain(srv, input_ret)
elif scene == "entertain2":
return self.entertain2(srv, input_ret)