Gazebo | Ignition | Community
Ask Your Question

How to delete links from a model? (Gazebo 1.2.5)

asked 2012-12-20 05:57:16 -0500

AndreiHaidu gravatar image


I have a model that is composed of numerous spheres as links. At a moment during the simulation I would like to remove some of these spheres (links).

I tried it this way and nothing happens:

// Initialize world (WorldPlugin)
physics::WorldPtr my_world = _parent;

// Init 'liquid_spheres' the model with many sphere links
physics::ModelPtr liquid_model = this->my_world->GetModel("liquid_spheres");

// Create a vector with all the links from the model
std::vector<physics::LinkPtr> links = this->liquid_model->GetAllLinks();

// I try to remove the links with "RemoveChild(EntityPtr _child)", but nothing happens
// Other operations such as moving them in another position works fine

// This one does not do anything either:

If it not possible to remove the links, which is the best way to delete the whole model?
I am using ROS Groovy with Gazebo 1.2.5.

Thanks, Andrei

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-07-23 17:43:09 -0500

nkoenig gravatar image
edit flag offensive delete link more

answered 2013-01-11 19:28:31 -0500

scpeters gravatar image

updated 2013-01-11 19:28:54 -0500

Since we are using boost::shared_ptr for the links, the links will not be deleted until all copies of the pointer are gone. You should try clearing the links vector after calling liquid_model->RemoveChild, and then checking the links again.

edit flag offensive delete link more


Thank you for the answer, I will try it and come back with the updates.

AndreiHaidu gravatar imageAndreiHaidu ( 2013-01-12 04:15:28 -0500 )edit

I tried clearing the link vector one by one after each Remove op. with links.erase(links.end()); And with clearing the whole vector at the end with links.clear(); None of them worked, the spheres are still there, they do behave weirdly though. (They follow the other spheres around).

AndreiHaidu gravatar imageAndreiHaidu ( 2013-01-14 06:49:54 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2012-12-20 05:57:16 -0500

Seen: 825 times

Last updated: Jul 23 '13