ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Applying color in Gazebo without setting color material in urdf

asked 2023-04-14 02:49:57 -0600

huhahaha gravatar image

I am using Ubuntu 20.04 noetic.

This is a question that arose while creating the urdf file. I know that usually after loading STL from urdf, I have to set the material for the link through gazebo.xacro so that the color is reflected in the gazebo virtual environment.

Here I would like to ask a question about whether it is possible to reflect colors in the Gazebo virtual environment without setting the material color. (For example, if there is a color of a real object, it means that it is reflected as it is in the gazebo environment)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-04-14 11:59:25 -0600

shonigmann gravatar image

I'm not sure I understand your question...

But if you are asking how you can apply color or texture to models in Gazebo, there are a few ways.

  • you can add material tags to your URDF file (notably, this will be different for Gazebo than it will be for other tools like RViz) (most people's preferred approach for simple, uniform colors)
  • you can use a Collada / .dae file that has texture and material properties baked in (most people's preferred approach for more complex textures). Then simply reference this file in the geometry tags of your URDF instead of the .stl that you currently use and you should see your textured model in Gazebo. Blender is a great tool for this.
  • in Gazebo >= 8, you can use a Wavefront / .obj file to define materials. In my experience this is less portable than the Collada format
  • You could add an Ogre material script (i've always found this process to be clunky)

Some resources:

edit flag offensive delete link more

Comments

To put it simply, I would like to ask if the color is applied in gazebo if you change it to the color you want through a program like blender without setting the material in urdf, convert it into an stl or dae file, and import it into urdf.

huhahaha gravatar image huhahaha  ( 2023-04-14 20:49:27 -0600 )edit

Gazebo only knows about meshes based on the filepath that is provided in the URDF/SDF file it receives. If that filepath points to a .dae or .obj mesh (the only formats Gazebo supports texture information for), then you can change the colors/textures in the mesh in a program like Blender, and see the colors reflected in Gazebo when you reload the model, without the need to modify the URDF.

Gazebo does not support face or vertex color defined in a .stl file so any color information you encode in a .stl file will not be visible in Gazebo. So if your URDF currently points to a .stl file, you will need to do one of the above bullets to get color or texture.

shonigmann gravatar image shonigmann  ( 2023-04-15 11:27:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2023-04-14 02:49:57 -0600

Seen: 1,013 times

Last updated: Apr 14 '23