Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Change color of a link runtime

Hi, I'd like to change the color of a link runtime, i.e. accessing (via C++ API) to the material property of link1 in the following sdf:

    <model name ='sphere'>
        <pose>0 0 0 0 0 0</pose>
        <link name ='link1'>
          <pose>0 0 0 0 0 0</pose>
          <visual name ='visual'>
            <geometry>
                <sphere><radius>1</radius></sphere>
            </geometry>
            <material>
                <ambient>1 0 0 1</ambient>
                <diffuse>0 0 0 1</diffuse>
            </material>
          </visual>
        </link>
      </model>

Looking at the documentation (https://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/classgazebo_1_1physics_1_1Model.html) I was able to find several methods to access to other similar properties (e.g. gazebo::physics::Model::SetCollideMode) and also to the link (e.g. LinkPtr gazebo::physics::Model::GetLink) but nothing to access to visual and material properties. How can I do it?