Home | Tutorials | Wiki | Issues
Ask Your Question
3

URI paths to packages in the SDF model file?

asked 2014-07-07 16:06:44 -0600

silentwf gravatar image

updated 2014-07-07 16:17:54 -0600

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?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2014-12-10 12:14:18 -0600

peci1 gravatar image

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/usingaurdfingazebo-package-uris-not-described/?answer=6419#post-id-6419 .

edit flag offensive delete link more
0

answered 2016-12-28 03:20:51 -0600

prasad gravatar image

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 withinthe 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/... )

[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]

edit flag offensive delete link more
-1

answered 2014-07-07 18:24:37 -0600

nkoenig gravatar image

SDF uses file instead of package:

<visual name='base_link_visual'>
    <pose>0 0 0 0 0 0</pose>
    <geometry>
      <mesh>
        <scale>1 1 1</scale>
        <uri>file://path_to_dae/textured.dae</uri>
      </mesh>
    </geometry>
  </visual>

or you can use the model uri:

<visual name='base_link_visual'>
    <pose>0 0 0 0 0 0</pose>
    <geometry>
      <mesh>
        <scale>1 1 1</scale>
        <uri>model://model_name/meshes/textured.dae</uri>
      </mesh>
    </geometry>
  </visual>

SDF will use ERB in the near furture. This will essentially add ruby scripting into SDF. Here is an example.

edit flag offensive delete link more

Comments

So basically saying that it is impossible to have the functionality to search for package path like the way URDF does it then?

silentwf gravatar imagesilentwf ( 2014-07-07 19:12:11 -0600 )edit

I think you may be able to use the uri tag to get similar functionality along with the `GAZEBO_MODEL_PATH` environment variable.

scpeters gravatar imagescpeters ( 2014-07-07 19:24:33 -0600 )edit

@scpeters I was also thinking something like that, but that kind of means lack of portability if I'm developing with ROS?

silentwf gravatar imagesilentwf ( 2014-07-07 21:27:39 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2014-07-07 16:06:44 -0600

Seen: 7,852 times

Last updated: Dec 10 '14