Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi,

i did something similar and recognized that i takes some time until the model is inserted correctly. Assuming you use

world_->InsertModelSDF(modelSDF);

you could wait a bit

common::Time::MSleep(500); // sleep half a second

before printing out all models. Also make sure the simulation is running and not paused. To access all models you can do something like:

for(std::vector<T>::iterator mod = world_->GetModels.begin(); mod != GetModels.end(); ++mod){
     printf("Model Name: %s",mod->GetName());
}

Hi,

i did something similar and recognized that i takes some time until the model is inserted correctly. Assuming you use

world_->InsertModelSDF(modelSDF);

you could wait a bit

common::Time::MSleep(500); // sleep half a second

before printing out all models. Also make sure the simulation is running and not paused. To access all models you can do something like:

for(std::vector<T>::iterator mod = world_->GetModels.begin(); mod != GetModels.end(); ++mod){
     printf("Model Name: %s",mod->GetName());
}

Two Edits to my Answer. They are probably not necessary! But i add them if someone runs in similar problems and the things above are not working:

MSleep(500) cause the thread to sleep, this may be problematic (or maybe not, depends :P). If its not working try to use:

  world_->Step(500);

instead.

In the for loop maybe use:

std::vector<physics::Model>::iterator mod = ......

and not the generic type.