I have a World plugin in which I need a pointer to a particular model's link. The problem is, that this plugin gets loaded before the model, therefor accessing the model's link results in failure. I tried to wait until the model is loaded as shown below.
physics::ModelPtr model = this->world->GetModel(model_name);
while(model == NULL) {
model = this->world->GetModel(model_name);
}
But this seems to induce a neverending loop. The model never gets loaded. I tried putting c++ usleep()
and roscpp ros::Duration(0.5).sleep()
in attempt to let the other processes load the world and the models in the meanwhile, but that does not help. Gazebo stucks in this loop.
Is there any way how to solve this?