Home | Tutorials | Wiki | Issues
Ask Your Question
0

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

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

AndreiHaidu gravatar image

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

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

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

nkoenig gravatar image
edit flag offensive delete link more
0

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

scpeters gravatar image

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

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

Comments

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

AndreiHaidu gravatar imageAndreiHaidu ( 2013-01-12 04:15:28 -0600 )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 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 373 times

Last updated: Jul 23 '13