-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
44 lines (35 loc) · 1.22 KB
/
test.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
#!/usr/bin/python
# _*_ coding: utf-8 -*-
import time
import RobotApi
RobotApi.ubtRobotInitialize()
#------------------------------Connect----------------------------------
gIPAddr = ""
robotinfo = RobotApi.UBTEDU_ROBOTINFO_T()
#The robot name you want to connect
robotinfo.acName="Yanshee_369E"
ret = RobotApi.ubtRobotDiscovery("SDK", 15, robotinfo)
if (0 != ret):
print ("Return value: %d" % ret)
exit(1)
gIPAddr = robotinfo.acIPAddr
ret = RobotApi.ubtRobotConnect("SDK", "1", gIPAddr)
if (0 != ret):
print ("Can not connect to robot %s" % robotinfo.acName)
exit(1)
#-----------------------↓ block program start here ↓----------------------
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, "谢谢")
#-----------------------↑ block program end ↑----------------------
RobotApi.ubtRobotDisconnect("SDK","1",gIPAddr)
RobotApi.ubtRobotDeinitialize()