Gazebo | Ignition | Community
Ask Your Question
0

Change color of a link runtime

asked 2016-02-12 08:09:22 -0500

randaz gravatar image

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.amazona...) 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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-02-12 11:35:01 -0500

chapulina gravatar image

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.

edit flag offensive delete link more

Comments

1

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

hsu gravatar imagehsu ( 2016-02-12 11:47:35 -0500 )edit
2

Question Tools

1 follower

Stats

Asked: 2016-02-12 08:09:22 -0500

Seen: 2,585 times

Last updated: Feb 12 '16