-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
executable file
·95 lines (61 loc) · 1.95 KB
/
main.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
import os, sys
import qi
pip = os.getenv('PEPPER_IP')
pport = 9559
pdir = os.getenv('PEPPER_TOOLS_HOME')
sys.path.append(pdir + '/cmd_server')
import pepper_cmd
from pepper_cmd import *
url = "tcp://" + pip + ":" + str(pport)
def naoqiAPI():
# session = qi.Session()
# session.connect("tcp://{}:{}".format(pip, str(pport)))
app = qi.Application(["App", "--qi-url=" + url])
app.start()
session = app.session
memory_service = app.session.service("ALMemory")
# ALDialog = session.service("ALDialog")
# voice only
tts_service = session.service("ALTextToSpeech")
tts_service.setLanguage("English")
tts_service.setParameter("speed", 90)
tts_service.say("Hello world")
# voice and gestures
ans_service = session.service("ALAnimatedSpeech")
configuration = {"bodyLanguageMode":"contextual"}
ans_service.say("Hello. How are you?", configuration)
# normal posture
rp_service = session.service("ALRobotPosture")
posture = "Stand"
speed = 0.7
rp_service.goToPosture(posture,speed)
# touch sensors
touch_service = session.service("ALTouch")
sl = touch_service.getSensorList() # vector of sensor names
print(sl)
v = touch_service.getStatus() # vector of sensor status [name, bool]
print(v)
# callback function
anyTouch = memory_service.subscriber("TouchChanged")
idAnyTouch = anyTouch.signal.connect(onTouched)
#anyTouch.signal.disconnect(idAnyTouch)
app.run()
def onTouched(value):
print("Test"*5)
def pepper_cmd_api():
begin() # connect to robot/simulator with IP in PEPPER_IP env variable
# see pepper_tools/cmd_server/pepper_cmd.py
pepper_cmd.robot.startSensorMonitor()
pepper_cmd.robot.say("Hello World")
# # start grabbing
# pepper_cmd.robot.startFrameGrabber()
# # Take and save picture
# filename = "grab.png"
# pepper_cmd.robot.saveImage(filename)
# # stop grabbing
# pepper_cmd.robot.stopFrameGrabber()
# pepper_cmd.robot.dance()
end()
if __name__ == "__main__":
print(os.getenv('PEPPER_TOOLS_HOME'))
pepper_cmd_api()