当前位置: 首页 > backend >正文

Autoware播放提示音

播放提示音

1、修改sound_player.yaml

src/autoware/utilities/sound_player/scripts/sound_player.yaml

'start'        : ~/Autoware/install/sound_player/share/sound_player/start.wav
'stop'         : ~/Autoware/install/sound_player/share/sound_player/stop.wav
'red signal'   : ~/Autoware/install/sound_player/share/sound_player/red.wav
'green signal' : ~/Autoware/install/sound_player/share/sound_player/green.wav
'pedestrian'   : ~/Autoware/install/sound_player/share/sound_player/pede.wav
'ndt warning'   : ~/Autoware/install/sound_player/share/sound_player/ndt_warning.wav
'deceleration'   : ~/Autoware/install/sound_player/share/sound_player/deceleration.wav
'return to normal run'   : ~/Autoware/install/sound_player/share/sound_player/return_normal.wav

2、运行sound_player

$ rosrun sound_player sound_player.py
loading sound_player.yaml
[INFO] [1625024290.737267]: sound_play node is ready to play sound

 3、播放

rostopic pub -1 /sound_player std_msgs/String -- 'start'

$ rostopic pub -1 /sound_player std_msgs/String -- 'start'
publishing and latching message for 3.0 seconds

sound_player运行窗口可以看到如下提示,同时可以听到声音。

autoware@3890dae21c45:~/Autoware$ rosrun sound_player sound_player.py
loading sound_player.yaml
[INFO] [1625024290.737267]: sound_play node is ready to play sound
[INFO] [1625024457.877442]: Playing "/home/autoware/Autoware/install/sound_player/share/sound_player/start.wav".
[WARN] [1625024459.052261]: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.

 遇到过的问题

 Autoware中的sound_player包,引用ROS中的sound_play包进行播放声音。sound_play的源码位于/opt/ros/melodic/lib/python2.7/dist-packages/sound_play。直接用sound_play进行播放声音测试,提示如下错误。

$ rosrun sound_play soundplay_node.py
[ERROR] [1625022115.086178]: Exception in callback: 'NoneType' object has no attribute 'set_property'
[INFO] [1625022115.089600]: Traceback (most recent call last):File "/opt/ros/melodic/lib/sound_play/soundplay_node.py", line 306, in callbacksound = self.select_sound(data)File "/opt/ros/melodic/lib/sound_play/soundplay_node.py", line 284, in select_soundself.builtinsounds[data.sound] = soundtype(params[0], self.device, volume)File "/opt/ros/melodic/lib/sound_play/soundplay_node.py", line 86, in __init__self.sink.set_property("device", device)
AttributeError: 'NoneType' object has no attribute 'set_property'[ERROR] [1625022115.092839]: Exception in dispose: soundtype instance has no attribute 'bus'

 播放声音时,提示上述错误,需要安装gstreamer1.0-alsa。

$ sudo apt-get install gstreamer1.0-alsa
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:gstreamer1.0-alsa
0 upgraded, 1 newly installed, 0 to remove and 423 not upgraded.
Need to get 35.5 kB of archives.
After this operation, 204 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gstreamer1.0-alsa amd64 1.14.5-0ubuntu1~18.04.3 [35.5 kB]
Fetched 35.5 kB in 1s (39.8 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package gstreamer1.0-alsa:amd64.
(Reading database ... 154190 files and directories currently installed.)
Preparing to unpack .../gstreamer1.0-alsa_1.14.5-0ubuntu1~18.04.3_amd64.deb ...
Unpacking gstreamer1.0-alsa:amd64 (1.14.5-0ubuntu1~18.04.3) ...
Setting up gstreamer1.0-alsa:amd64 (1.14.5-0ubuntu1~18.04.3) ...

安装后可以成功播放声音,在外接喇叭可以听到声音。

python测试脚本

play.py

$ rosrun sound_play play.py  /home/autoware/Autoware/install/sound_player/share/sound_player/start.wav
[INFO] [1625023789.377876]: Playing "/home/autoware/Autoware/install/sound_player/share/sound_player/start.wav".

say.py

$ rosrun sound_play say.py autoware
[INFO] [1625026123.239788]: Saying: autoware
[INFO] [1625026123.243267]: Voice: voice_kal_diphone
[INFO] [1625026123.245115]: Volume: 1.0

playbuiltin.py

$ rosrun sound_play playbuiltin.py 2
[INFO] [1625026287.861512]: Playing sound 2.

test_actionlib_client.py

$ rosrun sound_play test_actionlib_client.py
[INFO] [1625026332.808348]: Need Unplugging
[INFO] [1625026336.831329]: End Need Unplugging
[INFO] [1625026336.834814]: Need Plugging
[INFO] [1625026338.862937]: End Need Plugging
[INFO] [1625026338.866100]: Say
[INFO] [1625026343.418829]: End Say
[INFO] [1625026343.421667]: Wav
[INFO] [1625026345.519853]: End wav

 test.py

$ rosrun sound_play test.py
[INFO] [1625026390.517195]: This script will run continuously until you hit CTRL+C, testing various sound_node sound types.
[INFO] [1625026390.520607]: wave
[INFO] [1625026392.556882]: quiet wave
[INFO] [1625026394.616173]: plugging
[INFO] [1625026396.622852]: quiet plugging
[INFO] [1625026398.629007]: unplugging
[INFO] [1625026400.634192]: plugging badly
[INFO] [1625026402.639162]: unplugging badly
[INFO] [1625026404.733889]: New API start voice
[INFO] [1625026407.738810]: New API start voice quiet
[INFO] [1625026410.745567]: New API wave
[INFO] [1625026412.750319]: New API wave quiet
[INFO] [1625026414.756173]: New API builtin
[INFO] [1625026416.762195]: New API builtin quiet
[INFO] [1625026418.767568]: New API stop

http://www.xdnf.cn/news/5323.html

相关文章:

  • ospf实验报告
  • Markdown—LaTeX 数学公式
  • 深入解析路由策略:从流量控制到策略实施
  • DAX 权威指南1:DAX计算、表函数与计算上下文
  • 《从零构建大模型》PDF下载(中文版、英文版)
  • python-django项目启动寻找静态页面html顺序
  • 洛图报告中的 FSHD 是什么?—— 解密九天画芯推动的三色光源显示技术
  • PDF转Excel工具推荐 小巧免费批量自动转换
  • Plant Simulation 基于Windows消息系统跨线程通讯方案
  • 使用 librosa 测量《忘尘谷》节拍速度
  • 【Linux基础】文件查找和文本处理指令
  • 天线的PCB设计
  • 数据结构·ST表
  • diy装机成功录
  • Vue3组件通信 emit 的工作原理
  • 真人配音与AI创作有声读物
  • 操作系统学习笔记第1章 (竟成)
  • List接口
  • C PRIMER PLUS——第7节:指针
  • Day 3:Warp协作功能深度实战
  • 运放OP方向技术要点和大厂题目解析
  • 文件IO之系统IO
  • dockerfile编写入门
  • 十六、统一建模语言 UML
  • 16前端项目----交易页
  • QT6 源(90):阅读与注释 LCD显示类 QLCDNumber ,源代码以及属性测试。该类继承于容器框架 QFrame
  • Windows报错:OSError: [WinError 1455] 页面文件太小,无法完成操作的问题
  • Redis能保证数据不丢失吗之RDB
  • 【Web】使用Vue3开发鸿蒙的HelloWorld!
  • 模拟太阳系(C#编写的maui跨平台项目源码)