Gazebo | Ignition | Community
Ask Your Question
0

Adding multiple models in gazebo using c++ api

asked 2020-06-03 23:58:22 -0500

cadbury gravatar image

Is it possible to add multiple objects with c++ api in gazebo? I have used methods given in this tutorial for adding models from a sdf file. But if the sdf file contains more than one model, it is only adding the first model. Can anyone please tell me if there is a way to add multiple models from the sdf file. Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-06-05 15:51:04 -0500

zokowc gravatar image

An SDF model file may only contain one model, thus why only the first model is being loaded. You can:

  • Put each model in its own SDF file and load each file separately
  • Create a .world file that contains all your models
  • Create a nested SDF file as seen in this tutorial: http://gazebosim.org/tutorials?tut=ne...
edit flag offensive delete link more

Comments

Thanks for your reply, but actually the entire sdf file is provided by some user and I have to insert those models at runtime. Can you suggest me how to insert multiple models at runtime?

cadbury gravatar imagecadbury ( 2020-06-08 02:49:40 -0500 )edit

You can add models at run time using two different methods(The ones I know off):

  1. In terminal, using(where model_0 is the name of your model):

    gz model -m model_0 -f path_to_model.sdf

  2. Through python using rosservices as outlined in this answer https://answers.gazebosim.org//questi...

  3. Method 2 can be replicated in C++

zokowc gravatar imagezokowc ( 2020-06-08 11:59:58 -0500 )edit

Thanks I will check that

cadbury gravatar imagecadbury ( 2020-06-09 00:35:06 -0500 )edit

Anytime! Please mark this answer correct if it works for you.

zokowc gravatar imagezokowc ( 2020-06-15 13:05:44 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-06-03 23:58:22 -0500

Seen: 535 times

Last updated: Jun 05 '20