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

Revision history [back]

click to hide/show revision 1
initial version

Thanks for a well documented question. I was trying to accomplish the same thing. After seeing your post, I decided to try a different approach. I came up with something that was good enough for me. Instead of going through and generating a material through OGRE and Gazebo, I built the colors in sdf using xacro. Based on your example repository and because you are posting in the ROS forums, I presume you are trying to apply these colors to a urdf file which gets loaded into gazebo.

My solution is to use an xacro marco to define a color using sdf xml.

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
  <xacro:macro name="material_olive_green">
  <visual>
    <material>
      <ambient>0.3137254 0.3254902 0.2352941 1</ambient>
      <diffuse>0.3137254 0.3254902 0.2352941 1</diffuse>
      <specular>0.1 0.1 0.1 1</specular>
      <emissive>0 0 0 0</emissive>
    </material>
  </visual>
</xacro:macro>
</robot>

Then I call the macro as part of my gazebo element in my robot file.

<gazebo reference="${prefix}base_link">
  <xacro:material_olive_green />
  <turnGravityOff>true</turnGravityOff>
</gazebo>

Hopefully this is useful to somebody.