0
$\begingroup$

Gazebo Answers logo

Hi Dear All,

I want to change color of models in gazebo ( standalone version 1.8.6 ), i read some comments here, but those don't work, by the way any one can help me? for example i want to change color of Cube 20k, and i don't know what is tag of color?!! and also i can't fine any property for color in gazebo! because i use standalone version of gazebo, i use SDF, for Example SDF file of Cube20k is:

<?xml version="1.0" ?>
<sdf version="1.4">
  <model name="cube_20k">
    <link name="link">
      <pose>0 0 0.5 0 0 0</pose>
      <collision name="collision">
        <geometry>
          <mesh>
            <uri>model://cube_20k/meshes/cube_20k.stl</uri>
            <scale>0.5 0.5 0.5</scale>
          </mesh>
        </geometry>
      </collision>
      <visual name="visual">
        <geometry>
          <mesh>
            <uri>model://cube_20k/meshes/cube_20k.stl</uri>
            <scale>0.5 0.5 0.5</scale>
          </mesh>
        </geometry>
      </visual>
    </link>
  </model>
</sdf>

i got this error when i added the material tag to SDF file:

XML Element[material], child of element[mesh] not defined in SDF. Ignoring.[mesh]
Error [parser.cc:710] Error reading element <mesh>
Error [parser.cc:710] Error reading element <geometry>
Error [parser.cc:710] Error reading element <collision>
Error [parser.cc:710] Error reading element <link>
Error [parser.cc:710] Error reading element <model>
Error [parser.cc:369] Unable to read element <sdf>
Error:   Could not find the 'robot' element in the xml file
         at line 61 in /tmp/buildd/ros-fuerte-urdfdom-0.2.3-3precise-20130312-1505/urdf_parser/src/model.cpp

I've added material tag to SDF file of Cube20K in this way, and now color of my Cube20k is changed

<?xml version="1.0" ?>
<sdf version="1.4">
  <model name="cube_20k">
    <link name="link">
      <pose>0 0 0.5 0 0 0</pose>
      <collision name="collision">
        <geometry>
          <mesh>
            <uri>model://cube_20k/meshes/cube_20k.stl</uri>
            <scale>0.5 0.5 0.5</scale>
          </mesh>
        </geometry>
      </collision>
      <visual name="visual">
        <geometry>
          <mesh>
            <uri>model://cube_20k/meshes/cube_20k.stl</uri>
            <scale>0.5 0.5 0.5</scale>
          </mesh>
        </geometry>
        <material>
          <ambient>1 0 0 1</ambient>
          <diffuse>1 0 0 1</diffuse>
          <specular>0.1 0.1 0.1 1</specular>
          <emissive>0 0 0 0</emissive>
        </material>
      </visual>
    </link>
  </model>
</sdf>

Originally posted by Vahid on Gazebo Answers with karma: 91 on 2013-06-26

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

In SDF you can use:

<visual name="castor_visual">
  <pose>-0.200 0 -0.12 0 0 0</pose>
  <geometry>
    <sphere>
      <radius>0.04</radius>
    </sphere>
  </geometry>
  <material>
    <ambient>1 0 0 1</ambient>
    <diffuse>1 0 0 1</diffuse>
    <specular>0.1 0.1 0.1 1</specular>
    <emissive>0 0 0 0</emissive>
  </material>
</visual>

Originally posted by nkoenig with karma: 7676 on 2013-06-27

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Vahid on 2013-06-28:
thank you so much, it's work :)

Comment by CroCo on 2022-09-12:
@nkoenig Why Gazebo is not able to detect <uri>file://media/materails/scripts/gazebo.material</uri?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.