How to delete a model entirely, including contact filter
Hi,
In my application I need to dynamically insert, delete and reinsert models. So when I delete a module and reinsert the same module at the same position with the same name, I will get an error which is
Error [ContactManager.cc:267] Filter with the same name already exists! Aborting
Meanwhile, I found that the object of the model is still there even after I 'delete' it use the function provided, which I believe is "Fini()".
So I ran a little test, which I added several lines in front of and after my delete function as follows
cout<<"World: This is a count of the object left: "<<currentWorld->GetModel(module_name).use_count()<<endl;
currentWorld->GetModel(module_name)->Fini();
cout<<"World: This is a count of the object left: "<<currentWorld->GetModel(module_name).use_count()<<endl;
Before I finalize the model, the count of the model instances are 23, and after that operation, the count drop to 7 instead of 1. I checked my entire code again and make sure I reset all the model_ptr instance I used. Therefore, it seems that we can never delete a model entirely.
Is this a bug or I massed something up in my code? Is there a solution without changing the name of the new inserted model? This functionality is crucial to our applications, so please help me!
By the way, the gazebo I used is 1.9.5. Have this been fixed in the new version?
Oh, also
currentWorld->GetPhysicsEngine()->GetContactManager()->GetContacts().size()
always gives me zero, so I don't know how to manually delete contact filter either.