Gazebo | Ignition | Community
Ask Your Question

How to add a color/material to a STL mesh in an URDF file?

asked 2016-06-23 04:52:50 -0600

pDotGetName gravatar image

I use STL meshes and urdf files and I can't seem to set the material colors in the urdf file. I tried adding material like this (similar to what I would do in an SDF file):

 <gazebo reference="link_name">


 <gazebo reference="link_name">

But it wouldn't work.

So: How can I set material/colours for STL files in an urdf file?

edit retag flag offensive close merge delete


Was this ever resolved?

plusk01 gravatar imageplusk01 ( 2017-01-05 00:14:26 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-06-25 10:06:59 -0600

mrslvgg gravatar image

updated 2016-06-27 03:58:16 -0600

You need to define the color separately such as in the file materials.xacro:

  <material name="Orange">
    <color rgba="${255/255} ${108/255} ${10/255} 1.0"/>

Import materials.xacro in your file:

<xacro:include filename="$(find your_robot_description)/urdf/materials.xacro" />

Then you can use the color specifying a material tag for each link, such as:

<link name="$link_name">
    <material name="Orange"/>

For further information visit:

edit flag offensive delete link more


Well, that's basically how I do it. But the model doesn't change color even when I switch from Gazebo/White to Gazebo/Orange.

pDotGetName gravatar imagepDotGetName ( 2016-06-27 03:16:01 -0600 )edit

I edited my answer. Check the new method.

mrslvgg gravatar imagemrslvgg ( 2016-06-27 03:59:34 -0600 )edit

Isn't this edit's material for the ROS visualization? I currently have something like this: <visual> ... <material name="Orange"/> </visual> ... <gazebo reference="link"> <material>Gazebo/Orange</material> </gazebo> In RVIZ the color is shown correctly, but in Gazebo it remains white. Could the STL file be somehow broken?

pDotGetName gravatar imagepDotGetName ( 2016-06-27 06:36:21 -0600 )edit

This did not work for me, the model did not change colors.

JeremySMorgan gravatar imageJeremySMorgan ( 2018-11-30 02:27:19 -0600 )edit
Login/Signup to Answer

Question Tools



Asked: 2016-06-23 04:52:50 -0600

Seen: 32,009 times

Last updated: Jun 27 '16