It is possible using a weird hack.
In the package.xml
of the package where you want to load the model (or just any package that gets loaded before your models are needed), declare the following export:
<export>
<!-- gazebo_ros_paths_plugin automatically adds these to
GAZEBO_PLUGIN_PATH and GAZEBO_MODEL_PATH when you do this export inside
the package.xml file. You can than use URIs of type model://my_package/stuff. -->
<gazebo_ros
gazebo_plugin_path="${prefix}/lib"
gazebo_model_path="${prefix}/.." />
</export>
After doing this and loading the package (running a node from it? don' know exactly), you're allowed to specify things like <uri>model://my_package/models/foo.dae</uri>
.
The ${prefix}/..
means to add the parent of your package directory to the model path, which should usually be the workspace itself. So then you can reference all packages from that workspace. If you need models from a different workspace, I think you have to declare the export
in all needed workspaces somewhere.
I've learnt this knowledge from http://answers.gazebosim.org/question/6416/using_a_urdf_in_gazebo-package-uris-not-described/?answer=6419#post-id-6419 .
Originally posted by peci1 with karma: 186 on 2014-12-10
This answer was ACCEPTED on the original site
Post score: 5
Original comments
Comment by arprice on 2020-06-16:
Note that you need to add an exec_depend
on gazebo_ros
to your package. test_depend
didn't do the export properly for me. You can check that the exports are found correctly with rospack plugins --attrib=gazebo_model_path gazebo_ros