Gazebo | Ignition | Community
Ask Your Question

Know if a model exists in my Gazebo Simulation

asked 2017-07-12 10:48:46 -0500

blevesque gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-07-12 11:51:48 -0500

chapulina gravatar image

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.

edit flag offensive delete link more


I will try this thanks:)

blevesque gravatar imageblevesque ( 2017-07-12 11:55:13 -0500 )edit

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 ?

blevesque gravatar imageblevesque ( 2017-07-13 04:59:22 -0500 )edit

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.

chapulina gravatar imagechapulina ( 2017-07-13 09:17:54 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-07-12 10:48:46 -0500

Seen: 855 times

Last updated: Jul 12 '17