Robotics StackExchange | Archived questions

Know if a model exists in my Gazebo Simulation

Hi, is there a way to get all model names in my simulation ?
I need to check in a C++ node if a model is instanciated in my gazebo simulation.

Thanks for help

Asked by blevesque on 2017-07-12 10:48:46 UTC

Comments

Answers

You can write a world plugin. On that example, _parent is a pointer to physics::World. So you can use _parent->GetModel("modelname"), if it returns null there is no model with that name in the world.

Asked by chapulina on 2017-07-12 11:51:48 UTC

Comments

I will try this thanks:)

Asked by blevesque on 2017-07-12 11:55:13 UTC

But a world plugin is used only when I instanciate my gzserver/world right ? Can I check my models whenever I want even after simulation launch ?

Asked by blevesque on 2017-07-13 04:59:22 UTC

From a different process, you could subscribe to Gazebo topics ~/model/info or ~/model/pose which will be triggered at least once the moment the model is inserted. Or you could create a request for entity_info at any time.

Asked by chapulina on 2017-07-13 09:17:54 UTC