Gazebo | Ignition | Community
Ask Your Question

How to use custom textures on urdf models in gazebo?

asked 2017-05-23 16:54:21 -0500

Gieseltrud gravatar image


I am using ROS Kinetic with Gazebo 7.x and I know that I can use gazebo materials with

<gazebo reference="link">

I did manage to use a custom .jpg file as a texture on my model by

  • editing the gazebo.materials script from usr/share/gazebo-7/media/materials/scripts

  • adding the .jpg file into the usr/share/gazebo-7/media/materials/textures folder.

However, since those folders are supposed to be read only and editing those does not seem right, I want to know a different way. I did read about adding the following to my package.xml, but I did not have any success with it.

    <gazebo gazebo_media_path="${prefix}"/>

My package has the following structure:

  • test_gazebo
    • package.xml
    • CMakeList.txt
    • launch/
    • media/
      • materials/
        • scripts/
          • test.materials
        • textures/
          • test.jpg
    • models/
      • test.urdf
    • ...

Is the structure wrong for the media export to work? From what I understood ${prefix} is the path to the package and gazebo should use it to use the media folder, but it does not work for me.

Do I need to change the .urdf if I am using a different media path also? What I tried is using the in my script asigned name like

  <gazebo reference="link">

Anyone might be able to help me out and knows what I am doing wrong?

edit retag flag offensive close merge delete


Do you mean "editing the gazebo.materials script" or "editing the gazebo.material script"? Also is your file named "test.materials" or "test.material" ? Just checking because I have the same problem as you had and I still cannot resolve the issue. Thanks!

Roberto Z. gravatar imageRoberto Z. ( 2019-05-07 01:57:57 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-10-04 08:35:32 -0500

kumpakri gravatar image

updated 2018-10-05 03:52:25 -0500

If you set your resources path to any folder with a structure


you can use any material you define in those folders just as if you were using the material form the /usr/share/gazebo-x folder.

Just add

export $GAZEBO_RESOURCE_PATH=/path/to/your/resource/folder

to the ~/.bashrc file. I, for example, use the ~/.gazebo folder for my materials and models.

EDIT Today I have found more convenient way how to set environment variables for gazebo-ros projects that I want to add to this answer.

You can also set the environment variables in your launch file like that

<env name="GAZEBO_MODEL_PATH" value="$(find robot_gazebo)/models"/>
<env name="GAZEBO_RESOURCE_PATH" value="$(find robot_gazebo)/media/materials"/>
edit flag offensive delete link more

answered 2018-10-03 11:20:34 -0500

hbaqueiro gravatar image

Take a look on those two questions, I believe they have all the information you need:

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-05-23 16:50:18 -0500

Seen: 7,391 times

Last updated: Oct 05 '18