Gazebo | Ignition | Community
Ask Your Question

ConnectDeleteEntity event doesn't work in World Plugin

asked 2017-01-31 08:43:23 -0600

Benoit gravatar image

Hello everybody,

I want to make a world plugin with events callback, everything work perfectly except the ConnectDeleteEntity event. With the following code, when we create a model, we get a "Add" message (the function "OnAddEntity" is called) but when remove a model (for example, by selecting a model and pressing the Delete Key, or with the menu), the function "OnDeleteEntity" is not called.

    namespace gazebo{
        struct PluginGazebo : public WorldPlugin {      
            event::ConnectionPtr DeleteEntityConnection;
            event::ConnectionPtr AddEntityConnection;
            void OnDeleteEntity(const std::string str){
                std::cerr << "Delete " << str << std::endl;
            void OnAddEntity(const std::string str){
                std::cerr << "Add " << str << std::endl;
                virtual void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf){
                    this->DeleteEntityConnection = event::Events::ConnectDeleteEntity(boost::bind(&PluginGazebo::OnDeleteEntity, this, _1)); 
                    this->AddEntityConnection = event::Events::ConnectAddEntity(boost::bind(&PluginGazebo::OnAddEntity, this, _1)); 


When OnDeleteEntity should be called ?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-01-31 10:31:11 -0600

chapulina gravatar image

It looks like the deleteEntity event is never being fired by Gazebo, which is a bug. I ticketed an issue here.

A workaround for now would be to subscribe to the ~/request topic and check if _msg->request() == "entity_delete", see an example here.

edit flag offensive delete link more


Your workaround works perpectly ! Thanks a lot.

Benoit gravatar imageBenoit ( 2017-02-01 04:59:15 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-01-31 08:42:19 -0600

Seen: 267 times

Last updated: Jan 31 '17