Gazebo | Ignition | Community
Ask Your Question

Is there a memory leak when changing visual color from model plugin?

asked 2017-11-29 04:27:14 -0500

elcymon gravatar image

updated 2017-11-29 04:32:28 -0500

I am trying to change the visual of a mobile robot based on the state of the robot. Though this works (i.e. the visual of the model changes to the desired color), the gazebo simulator starts to freeze. When I delete the section of code that changes the model's colour, gazebo simulation works as normal (i.e. without freezing).

Please what am I doing wrong here?

This is the code snippet:

        gazebo::common::Color newColor(0.0,1.0,0.0,1.0);
        msgs::Color *homColMsg = new gazebo::msgs::Color(gazebo::msgs::Convert(newColor));
        msgs::Color *homDiffMsg = new gazebo::msgs::Color(*homColMsg);
        gazebo::physics::LinkPtr link = this->model->GetLink("chassis");

        msgs::Visual visMsg = link->GetVisualMessage("visual");
        msgs::Material *materialMsg = visMsg.mutable_material();




The inspiration for this approach is from: handsim implementation

edit retag flag offensive close merge delete


Interesting that on Handsim the link name is used on the visual message, I'd expect that to be the visual name. i.e. `model::link::visual` instead of `model::link`

chapulina gravatar imagechapulina ( 2017-11-29 10:37:26 -0500 )edit

I changed it to 'model::link::visual' and it works fine now! Thanks.

elcymon gravatar imageelcymon ( 2017-11-29 10:57:46 -0500 )edit

Great! I added an answer so feel free to accept it and close the question ;)

chapulina gravatar imagechapulina ( 2017-11-29 11:05:17 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-29 11:03:09 -0500

chapulina gravatar image

As mentioned on the comments, the solution was to use the scoped visual name instead of the scoped link name.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-11-29 04:27:14 -0500

Seen: 191 times

Last updated: Nov 29 '17