Gazebo | Ignition | Community
Ask Your Question

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'>
                <ambient>1 0 0 1</ambient>
                <diffuse>0 0 0 1</diffuse>

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

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



Another example in a world plugin handsim/src/b6415df144217a6bf40b3f2265ae3ca079b89bfd/src/

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

Question Tools

1 follower


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

Seen: 2,573 times

Last updated: Feb 12 '16