Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

The problem is that you do not allow the destructor to return. Your thread never joins due to the service call.

You can use directly the gazebo interface to delete the model, which will allow you to do this asynchronously.

#include <gazebo/transport/Node.hh>
transport::NodePtr node = boost::make_shared<transport::Node>();
node->Init();
transport::PublisherPtr request_pub = node->Advertise<msgs::Request>("~/request");
msgs::Request *msg = msgs::CreateRequest("entity_delete", "<my_model_name>");
request_pub->Publish(*msg);
delete msg;

The problem is that you do not allow the destructor to return. Your thread never joins due to the service call.

You can use directly the gazebo interface to delete the model, which will allow you to do this asynchronously.

#include <gazebo/transport/Node.hh>
transport::NodePtr node = boost::make_shared<transport::Node>();
node->Init();
transport::PublisherPtr request_pub = node->Advertise<msgs::Request>("~/request");
msgs::Request *msg = msgs::CreateRequest("entity_delete", "<my_model_name>");
model->GetName());
request_pub->Publish(*msg);
delete msg;