Gazebo | Ignition | Community
Ask Your Question

World plugin tutorial, models not in the EntityTree

asked 2018-11-16 06:21:36 -0500

kincurt gravatar image


Following the World Plugin tutorial I noticed something strange.

After spawning the different models, they are not yet taken into account by the plugin. For instance if you try World::PrintEntityTree(), it won't show the spawned models.

Is there a way to acces spawned model in the world plugin?

Thanks for your help

edit retag flag offensive close merge delete


That is particularly useful to insert identical models without name conflicts (changing the name right after spawn) because gazebo won't allow to spawn two time in a row an identical model.

kincurt gravatar imagekincurt ( 2018-11-16 06:29:22 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-16 08:13:19 -0500

wentz gravatar image

updated 2018-11-21 03:56:34 -0500


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


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:



In the for loop maybe use:

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

and not the generic type.

edit flag offensive delete link more


Thanks ! :)

kincurt gravatar imagekincurt ( 2018-11-20 09:08:38 -0500 )edit

Your Welcome :) I edited my answer, if it is already working for you, you can ignore it.

wentz gravatar imagewentz ( 2018-11-21 03:57:24 -0500 )edit

Question Tools

1 follower


Asked: 2018-11-16 06:21:36 -0500

Seen: 654 times

Last updated: Nov 21 '18