问题描述
运行nav2中文官网的运行样例时,rviz2中可以正常执行nav2导航,但是gazebo就是加载不出来。一直卡在 Preparing your world
的界面。
去网上搜都是要下载models到本地的~/.gazebo/models
中。这确实提供了解决问题的基本思路:缺少的models文件会从外网下载,网速很慢,所以会卡住,但是这种方法对于该文章nav2的问题并不能解决。
实际引发这个问题的原因是nav2的waffle.models
中的描述有误,只需要修改waffle.models
文件就可以解决问题,根本不需要从官网下东西(如果跑别的样例不能保证,但思路是一样的)
问题排查过程
在/opt/ros/foxy/share/nav2_bringup/worlds/waffle.models
文件中,左右轮mesh加载的是left_tire.dae
和right_tire.dae
重点:但是实际上/opt/ros/foxy/share/turtlebot3_gazebo/models/
中的turtlebot3_waffle\meshes
文件夹中根本不包含这两个文件,实际只包含tire.dae
所以解决方法很简单,把/opt/ros/foxy/share/nav2_bringup/worlds/waffle.models
文件中的 两个mesh描述改成tire.dae
就好
总结
还是要从launch文件和models文件的源码排查,真正理解gazebo的加载原理,才能更好的处理问题。无脑下载models并不能解决问题。
参考答案
https://github.com/ros-planning/navigation2/issues/2571
gazebo models的github地址
https://github.com/osrf/gazebo_models/tree/turtlebot3
https://github.com/ROBOTIS-GIT/turtlebot3_simulations
nav2中文官网
http://fishros.org/doc/nav2/getting_started/index.html#running-the-example