-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreedom2.py
48 lines (33 loc) · 1.2 KB
/
freedom2.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
#!usr/bin/python
#coding=utf-8
import RobotApi as api
import RobotApi
import RestfulAPI as api2
import flask
import sys, Tkinter
import time
api.ubtRobotInitialize()
#------------------------------------------------------
ret = api.ubtRobotConnect('SDK', '1', '127.0.0.1')
if (0 != ret):
print('连接机器人%s失败' % robotinfo.acName)
exit(1)
#------------------------------------------------------
def go_face():
if (api.ubtVisionDetect ( 'face', '0', 10)==0):
api.ubtVoiceTTS ( 1, '我看到你了,正在向你走来')
length = RobotApi.UBTEDU_ROBOTINFRARED_SENSOR_T()
while True:
RobotApi.ubtReadSensorValue('infrared', length, 5)
time.sleep(3)
print(length.iValue)
if length.iValue >20:
api.ubtStartRobotAction('walk', 0)
else :
api.ubtSetRobotMotion('bow', 'front', 2, 1)
else:
api.ubtVoiceTTS(1, '没找到人脸')
go_face()
#--------------------------------------------------------
api.ubtRobotDisconnect('SDK', '1', '127.0.0.1')
api.ubtRobotDeinitialize()