Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

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

Hi,

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->liquid_model->RemoveChild(links[i]);

// This one does not do anything either:
this->liquid_model->RemoveChildren();


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