Gazebo | Ignition | Community
Ask Your Question
0

Know if a model exists in my Gazebo Simulation

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

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
0

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

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

Comments

I will try this thanks:)

blevesque gravatar imageblevesque ( 2017-07-12 11:55:13 -0600 )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 -0600 )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](https://bitbucket.org/osrf/gazebo/src/45f77842932c95d747d2f20df98aed613792b295/gazebo/gui/ModelListWidget.cc?fileviewer=file-view-default#ModelListWidget.cc-278) for `entity_info` at any time.

chapulina gravatar imagechapulina ( 2017-07-13 09:17:54 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 963 times

Last updated: Jul 12 '17