最近在搞ROS和Gazebo (是不是最近搞的东西有点多?),一个需求是希望Gazebo的world文件能够通过相对路径的方式引用保存在其他ros package内的文件。经过一番google,最后的解决方案是在包含有资源的package的package.xml文件最后,通过<export>
标签来增加Gazebo搜索model的路径,然后在world文件中使用形如<uri>model://<ros package>/<dir name>/mesh.dae</uri>
的资源描述。使用的<export>
标签如下
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
<gazebo_ros gazebo_model_path="${prefix}/.." plugin_path="${prefix}/lib" gazebo_media_path="${prefix}" />
</export>
参考:
- https://answers.gazebosim.org//question/6568/uri-paths-to-packages-in-the-sdf-model-file/
- https://answers.gazebosim.org//question/6416/using_a_urdf_in_gazebo-package-uris-not-described/?answer=6419#post-id-6419
- https://answers.gazebosim.org//question/16159/how-to-include-uri-relatively/
- http://gazebosim.org/tutorials/?tut=ros_plugins