-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetup1.py
36 lines (28 loc) · 1022 Bytes
/
getup1.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import RobotApi as api
api.ubtRobotInitialize()
#------------------------------Connect----------------------------------------
ret = api.ubtRobotConnect("SDK", "1", "127.0.0.1")
if (0 != ret):
print ("Can not connect to robot %s" % robotinfo.acName)
exit(1)
#---------------------------Read Sensor Value-------------------------------
while True:
time.sleep(3)
if (getRobotSensorValue("obstacle") <= 10):
#lights_chest.
api.ubtSetRobotLED("button", "red", "blink")
ubtinit.isSetLed = True
#sound_tts.
api.ubtVoiceTTS(0, "距离太近了,请离远点")
elif (getRobotSensorValue("obstacle") > 20):
#lights_chest.
api.ubtSetRobotLED("button", "yellow", "blink")
ubtinit.isSetLed = True
#sound_tts.
api.ubtVoiceTTS(0, "谢谢")
#---------------------------Disconnect--------------------------------------
api.ubtRobotDisconnect("SDK","1","127.0.0.1")
api.ubtRobotDeinitialize()