Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is it possible to change the color of an object in a Plugin?

Hi All,

I have this piece of sdf code:

<link name="crossbar_back_top">
  <pose>0 0.6 1.03125 1.57 0 1.57</pose>
  <collision name="collision">
    <geometry>
      <box>
        <size>0.0625 0.0625 2.650</size>
      </box>
    </geometry>
  </collision>
  <visual name="visual">
    <geometry>
      <box>
        <size>0.0625 0.0625 2.650</size>
      </box>
    </geometry>
    <material>
      <script>
        <uri>file://media/materials/scripts/gazebo.material</uri>
        <name>Gazebo/White</name>
      </script>
    </material>
  </visual>
</link>

Can I change the color of the material like:

sdf::ElementPtr elementPtr = myModelPtr->GetSDF(); if (elementPtr->HasElement("")) // <<--- What to insert here? { .... }

Thanks, Peter