Gazebo | Ignition | Community
Ask Your Question
0

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

asked 2019-10-12 05:21:53 -0500

PeterHer gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-10-14 07:47:46 -0500

chapulina gravatar image

I recommend you publish a message to ~/visual with the new color. See an example here.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-10-12 05:21:53 -0500

Seen: 449 times

Last updated: Oct 14 '19