< >
Home » walking机器人仿真教程_视频版 » walking机器人仿真教程-应用-多点导航结合音乐播放实现移动音箱

walking机器人仿真教程-应用-多点导航结合音乐播放实现移动音箱

walking机器人仿真教程-应用-多点导航结合音乐播放实现移动音箱

说明:

  • 介绍如何结合多点导航和音乐播放实现移动音箱
  • 想法:在房间内实现多点导航,到达每个航点后会随机自动播放一首音乐,播放完之后继续下一个航点,直到所有航点结束.
  • 实现原理:通过航点编辑器,保存带操作的航点文件,参考文章,再通过python3导航脚本读取航点文件,获取航点,进行导航,根据操作字段operate判断为PlayMusic,启动播放音乐.

步骤:

  • 加载gazebo
. /usr/share/gazebo/setup.bash 
  • 启动仿真
ros2 launch walking_application house_world_inspection.launch.py
  • gazebo效果:

请输入图片描述

  • rviz效果: 

请输入图片描述

  • 设计航点
  • 利用walking_navigation多点导航面板(参考)和目标点设置工具walkingGoal(参考),设定航点并保存航点

请输入图片描述

  • 保存文件到目录并命名:/home/ubuntu/waypoints/house_waypoints_music.json
  • 设置操作
  • 再利用航点编辑工具(参考),设置航点操作为PlayMusic

请输入图片描述

  • 编辑后保存文件到目录并命名为:/home/ubuntu/waypoints/house_waypoints_music_ed.json
  • 启动导航
ros2 run walking_application run_inspection_v2.py
  • 文件已经默认指定航点文件为/home/ubuntu/waypoints/house_waypoints_music_ed.json
  • 执行效果: 
$ ros2 run walking_application run_inspection_v2.py
pygame 2.1.2 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. https://www.pygame.org/contribute.html
[INFO] [1653474888.057387605] [basic_navigator]: Publishing Initial Pose
[INFO] [1653474892.074457651] [basic_navigator]: Nav2 is ready for use!
[INFO] [1653474892.081163843] [basic_navigator]: Navigating to goal: 3.16139913 -0.13622037...
Executing current waypoint: 1
Executing current waypoint: 1
Executing current waypoint: 1
Inspection 1 is complete! Returning to start...
don't have any operate
[INFO] [1653474907.134787479] [basic_navigator]: Navigating to goal: 6.59372425 -2.59195447...
Executing current waypoint: 2
Executing current waypoint: 2
Executing current waypoint: 2
Executing current waypoint: 2
Inspection 2 is complete! Returning to start...
Begin to play music!
play music is done!
[INFO] [1653475227.017869471] [basic_navigator]: Navigating to goal: 1.17916834 0.49717629...
Executing current waypoint: 3
Executing current waypoint: 3
Executing current waypoint: 3
Executing current waypoint: 3
Executing current waypoint: 3
Executing current waypoint: 3
Executing current waypoint: 3
Inspection 3 is complete! Returning to start...
Begin to play music!
  • 执行之后,自动在房间内导航,并到达一个航点之后,会播放音乐
  • 使用的音乐目录位于/home/ubuntu/Music下.可以自己更换音乐文件
  • 使用的航点文件位于/home/ubuntu/waypoints/house_waypoints_music_ed.json

演示视频

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: walking机器人仿真教程