Robotics StackExchange | Archived questions

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?

Asked by randaz on 2016-02-12 09:09:22 UTC

Comments

Answers

Material properties are usually not available from the physics API.

One way to do it is to publish a visual message to the ~/visual topic. Here's an example changing transparency.

Asked by chapulina on 2016-02-12 12:35:01 UTC

Comments

Another example in a world plugin handsim/src/b6415df144217a6bf40b3f2265ae3ca079b89bfd/src/HaptixWorldPlugin.cc?at=default&fileviewer=file-view-default#HaptixWorldPlugin.cc-1357

Asked by hsu on 2016-02-12 12:47:35 UTC