Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Thanks for answering.

I have tried to send a msg request to delete the model as you recommended it, but it couldn't recognize the light name and it gave me this when I run it: Msg Waiting for master Msg Connected to gazebo master @ http://127.0.0.1:11345 Msg Publicized address: 192.168.1.3 Error: No model name specified.

I also tried this with box model but it didnt work , I know that problem goes with recognizing the model name but I dont know how to do it even thouhgh I tried to get the model name in this way to delete the light

std::string modelName= _sdf->GetElement("light")->GetValueString();

but gazebo crashed and gave this error :gazebo: /usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr<t>::operator->() const [with T = sdf::Element]: Assertion `px != 0' failed.

The code below shows how it is done:

if ( this->model2_ ->GetWorld()->GetSimTime() > this->simtime )

{

// std::string modelName= _sdf->GetElement("light")->GetValueString();

if (!transport::init())

return;

if (vm.count("bulb100"))

modelName = vm["bulb100"].as<std::string>();

else

{

std::cerr << "Error: No model name specified.\n";

return;

}

transport::run();

transport::NodePtr node(new transport::Node());

node->Init();

msgs::Request *msg = msgs::CreateRequest("entity_delete", modelName);

transport::PublisherPtr pub = node->Advertise<msgs::request>("~/request");

// Model file to load

pub->WaitForConnection();

pub->Publish(*msg);

delete msg;

transport::fini();

}

thanks in advance!