Gazebo | Ignition | Community
Ask Your Question
0

URI for meshes not working in Fortress?

asked 2023-05-19 15:29:44 -0600

slim71 gravatar image

updated 2023-05-19 15:30:14 -0600

So, I'm trying to spawn a model in a running Ignition Fortress world (any will do, it doesn't change anything), through ROS2 Humble.

The model I'm using is this one, which as you can see uses <uri>model://X3/meshes/led.dae</uri> to load meshes and other stuff from the same folder in which model.sdf is located. The overall relevant structure is this:

workspace 
|- src   
   |- pkg1
      |- description
         |- X3
            |- meshes_folder
            |- model.sdf
      |- launch
         |- launch_model.py   
   |- pkg2
      |- launch_world.py

Of course both package have the conventional structure and the package.xml file; they still have only a launch file, but will be cmake_ament packages.

I can start Ignition with no problem, loading the desired world with the launch file from pkg2. I then use another launch file from pkg1 to load the X3 model, which is indeed found and loaded into Ignition but without meshes, as the terminal issues multiple lines like

Unable to find file with URI [model://X3/meshes/x3.dae]
Could not resolve file [model://X3/meshes/x3.dae]
Unable to find file[model://X3/meshes/x3.dae]
Mesh manager can't find mesh named [model://X3/meshes/x3.dae]
Cannot load null mesh [model://X3/meshes/x3.dae]
Failed to get Ogre item for [model://X3/meshes/x3.dae]
Failed to load geometry for visual: base_link_inertia_visual

and so on. I can't seem to understand how to get it working. I've seen multiple posts (like this one) about using

<gazebo_ros gazebo_model_path="${prefix}" />
<gazebo_ros gazebo_media_path="${prefix}" />

(or similar) being sure to also add <exec_depend>gazebo_ros</exec_depend> to the package.xml file and to install the directory in the package's share folder, like

install(
    DIRECTORY config description launch
    DESTINATION share/${PROJECT_NAME}
)

Even though I do this, I can't get it working.

Anyone has any suggestion?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-20 04:11:46 -0600

slim71 gravatar image

After another 12 hours, I've found an "alternate" solution, or the real one maybe.
Everything started from seeing this stuff about environment variables . In case the link breaks, the relevant part is

Gazebo will find your model as long as its parent path is listed on the environment variable GAZEBO_MODEL_PATH

(beware: in the link GAZEBO_MODEL_PATH is mentioned, but for me for Ignition Fortress the right one is IGN_GAZEBO_RESOURCE_PATH. You can find out yours by using ign help gazebo or similar, depending on your Gazebo/Ignition version)

Instead of the above, I've used environment hooks, found in this GitHub issue.
In the package loading the model (pkg1 in the example above) I added a folder env-hooks with a file <project_name>.dsv.in, in which I've put

prepend-non-duplicate;IGN_GAZEBO_RESOURCE_PATH;share/@PROJECT_NAME@/models
prepend-non-duplicate;IGN_GAZEBO_RESOURCE_PATH;share/@PROJECT_NAME@/worlds

adding every possible path I might need.
Then I made sure to hook it up adding

ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/env-hooks/${PROJECT_NAME}.dsv.in")

For reference, everything is also explained in the issue I've linked above, which points at this and this as examples. I bit of exaplanation on environment hooks is here, with more in depth explanations in the ColCon docs.


If anyone has good info for the package.xml solution, please feel free to add them here! I'll try it out to have a good reference point for both methods!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-05-19 15:29:44 -0600

Seen: 632 times

Last updated: May 20 '23