0
$\begingroup$

Gazebo Answers logo

Hi All,

I'm trying to create a SDF from COLLADA files I have already. However, the files I'm trying to link to are located in different files (I'm trying to load a sensor on the robot). In URDFs I could use the ($find package_name) method to get a location. How would I do that with the SDF file? This is part of what I have right now in the SDF file.

<visual name='base_link_visual'>
    <pose>0 0 0 0 0 0</pose>
    <geometry>
      <mesh>
        <scale>1 1 1</scale>
        <uri>package://my_package/Media/models/textured.dae</uri>
      </mesh>
    </geometry>
  </visual>

This won't link to my package.

Also, is it possible to use XACRO files with the SDF?


Originally posted by silentwf on Gazebo Answers with karma: 51 on 2014-07-07

Post score: 5

$\endgroup$

2 Answers 2

0
$\begingroup$

Gazebo Answers logo

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

$\endgroup$
0
$\begingroup$

Gazebo Answers logo

Typically, there are 3 methods to let Gazebo software load a model.

  1. Export GAZEBO_MODEL_PATH properly. (If Gazebo doesn't start at all, then setup Gazebo and environment variables and then export GAZEBO_MODEL_PATH)

  2. Move the models to "gazebo/models" folder directly and include the URI in launch file.

  3. In case this is being used with ROS (which is the typical case), make sure that the models and the code is within the workspace. (I was struggling with this and I was attempting multi-robot simulation. I realised that the environment variables are sourced in the first instance and sourcing them again from second workspace or any other folder can be difficult. Reference : http://wiki.ros.org/catkin/Tutorials/workspace_overlaying )

[Note: I am posting this to help people; I myself struggled to get a working solution (for about 10 hours) and I haven't found any similar information as in this answer]


Originally posted by prasad with karma: 11 on 2016-12-28

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.