Gazebo | Ignition | Community
Ask Your Question

How to modify a link's visual programmatically from a sensor plugin?

asked 2016-07-18 12:47:12 -0500

dhood gravatar image

I'm trying to modify the visual of a link from inside a sensor plugin (not a visual plugin).

I get access to the link with:

physics::LinkPtr link = boost::dynamic_pointer_cast<physics::Link>(this->world->GetEntity(linkName));

Eventually I'd like to use gazebo::rendering::Visual::SetRotation, but I can't figure out how to get to that point.

I have tried using:

msgs::Visual visual = link->GetVisualMessage("visual");

to get access to the visual, but after that I have not had any luck converting the gazebo::msgs::Visual to a gazebo::rendering::Visual.

Any tips for how to get access to a gazebo::rendering::Visual visual from a gazebo::physics::LinkPtr?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-07-18 15:40:14 -0500

chapulina gravatar image

It might be possible to modify a visual from a sensor plugin, but since that's not what sensor plugins are designed to do, it might take some effort. Actually I suspect it might be impossible...

I think the "proper" way to change a visual from anything other than a VisualPlugin would be to use the transport layer to publish a message to the ~/visual topic. In fact, that's what the physics library does under the hood when you call things like physics::Link::SetVisualPose.

So to change the visual pose, you could do:

this->visPub = this->node->Advertise<msgs::Visual>("~/visual", 200);

msgs::Visual visual;
visual.set_name(<vis name>);
visual.set_parent_name(<link name>);
visual.set_parent_id(<link id>);
msgs::Set(visual.mutable_pose(), <desired pose>);

You can see the visual message description here.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-07-18 12:47:12 -0500

Seen: 277 times

Last updated: Jul 18 '16