【项目回顾】基于Yanshee的AI服务型机器人(二) 您所在的位置:网站首页 机器人用语音怎么读 【项目回顾】基于Yanshee的AI服务型机器人(二)

【项目回顾】基于Yanshee的AI服务型机器人(二)

2023-07-10 21:04| 来源: 网络整理| 查看: 265

1月20日-1月25日 我参加了河海大学和深圳优必选公司联合举办的训练营 作为机器人领域的龙头企业,优必选公司的产品Alpha曾经登陆过春晚进行表演,这次活动中他们的机器人产品Yanshee也非常厉害 在训练营的末尾,我们小组用了一天半的时间做了一个小型的项目,当作我们的结营汇报,以下为项目内容。

功能1-4:【项目回顾】基于Yanshee的AI服务型机器人(一)

功能5-8:

通过网络爬虫程序获得当前城市当日的天气预报并通过语音播报通过红外传感器(Infrared Sensor)进行避障巡逻通过红外传感器(Infrared Sensor)进行遇障绕路行走通过摄像头的抓拍进行人脸识别、跟踪

这篇文章将回顾项目的第5-8项功能

5:通过网络爬虫程序获得当前城市当日的天气预报并通过语音播报

#!/usr/bin/python #_*_ coding:utf-8 _*_ import urllib import sys import RobotApi from bs4 import BeautifulSoup reload(sys) sys.setdefaultencoding('utf-8') def weather_get(): resp=urllib.urlopen('http://www.weather.com.cn/weather/101270101.shtml') soup=BeautifulSoup(resp,'html.parser') tagDate=soup.find('ul', class_="t clearfix") dates=tagDate.h1.string tagToday=soup.find('p', class_="tem") try: temperatureHigh=tagToday.span.string except AttributeError as e: temperatureHigh=tagToday.find_next('p', class_="tem").span.string temperatureLow=tagToday.i.string weather=soup.find('p', class_="wea").string tagWind=soup.find('p',class_="win") winL=tagWind.i.string print('今天是:'+dates) print('风级:'+winL) print('最低温度:'+temperatureLow) print('最高温度:'+temperatureHigh) print('天气:'+weather) a='今天是:'+str(dates) b='风级:'+str(winL) c='最低温度:'+str(temperatureLow) d='最高温度:'+str(temperatureHigh) e='天气:'+str(weather) RobotApi.ubtVoiceTTS(1,a) RobotApi.ubtVoiceTTS(1,b) RobotApi.ubtVoiceTTS(1,c) RobotApi.ubtVoiceTTS(1,d) RobotApi.ubtVoiceTTS(1,e)

因为天气信息分布在网络上,因此实现这个功能就要使用网络爬虫,又因为Yanshee中内置了Python 2.7的版本,所以这个程序使用了urllib和bs4两个模块,用sys模块进行编码,提取中国天气网上的信息,并通过文字转语音的接口输出出来。

6:通过红外传感器进行避障巡逻

import RobotApi from time import sleep def alert1(): i=1 while i300: ret = RobotApi.ubtSetRobotMotion("walk","front",5,1) i=i+1 else: RobotApi.ubtStopRobotAction() RobotApi.ubtVoiceTTS(1,"碰到障碍物") break

这个避障巡逻的思路很简单

if sensorValue1.iValue>300: ret = RobotApi.ubtSetRobotMotion("walk","front",5,1) i=i+1

当红外检测到300mm内没有障碍物的时候就执行向前走的动作,动作速度为5,重复次数为1 ubtSetRobotMotion的介绍 当向前走的次数超过七次的时候向左转,然后i的数值回到1,重复检测障碍物,向前行走

if i==7: ret = RobotApi.ubtSetRobotMotion("turn around","left",5,5) i=1

当遇到障碍物的时候,机器人停止动作并且播报:“遇到障碍物”

else: RobotApi.ubtStopRobotAction() RobotApi.ubtVoiceTTS(1,"碰到障碍物") break

7:通过红外传感器进行遇障绕路行走

import RobotApi from time import sleep def walk1(): k=1 l=0 i=1 while i


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有