0
$\begingroup$

Gazebo Answers logo

The versions of Gazebo that ship with the simulator_gazebo stack include a spawn_model script that calls the service /gazebo/spawn_gazebo_model or /gazebo/spawn_urdf_model to spawn a new model into an already-running world. However, drcsim doesn't provide either of these services. Is there some other way to programmatically spawn a model into an already running instance of the drcsim version of Gazebo? (I found some tutorials on modifying world contents, but they involve creating a new .world file, which is not what I want to do.) Or could I change something somewhere to make drcsim advertise the /gazebo/spawn_*_model topics?

(The reason I'm asking is because I'd like to use the drcsim version of Gazebo for something non-DRC-related that I'm doing, because it's newest and (presumably) most stable version of Gazebo that's integrated with ROS.)


Originally posted by Elizabeth C on Gazebo Answers with karma: 33 on 2013-04-03

Post score: 1

$\endgroup$

3 Answers 3

0
$\begingroup$

Gazebo Answers logo

I would recommend the command-line tool gzfactory. For some reason, we don't have a tutorial for it yet. To use it, you need a an sdf file. I used one of the model sdf files in the ~/.gazebo/models folder. For example to spawn a hokuyo sensor (make sure it's in your .gazebo/models folder first):

gzfactory spawn -f ~/.gazebo/models/hokuyo/model-1_3.sdf

To spawn another, you'll need to specify a different name, and you'll probably want to put it somewhere else:

gzfactory spawn -f ~/.gazebo/models/hokuyo/model-1_3.sdf -m hokuyo_1 -x 1

Here's the help output that I see when typing gzfactory:


This tool for spawning or deleting models into or from a running Gazebo simulation.

  gzfactory  [options]
    spawn   : Spawn new model. Must specify a SDF model file.
    delete  : Delete existing model. Must specify model name.


Allowed options:
  -h [ --help ]           produce this help message
  -f [ --sdf ] arg        SDF model file.
  -w [ --world-name ] arg Name of Gazebo world.
  -m [ --model-name ] arg Model name.
  -x [ --pose-x ] arg     set model x position.
  -y [ --pose-y ] arg     set model y position.
  -z [ --pose-z ] arg     set model z positione.
  -R [ --pose-R ] arg     set model roll orientation in radians.
  -P [ --pose-P ] arg     set model pitch orientation in radians.
  -Y [ --pose-Y ] arg     set model yaw orientation in radians.

Originally posted by scpeters with karma: 2861 on 2013-04-04

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by Elizabeth C on 2013-04-21:
Thank you! Problem is, this doesn't work for URDF files, which is what all the models I'm using are. I guess I didn't specify that in my original question, though, so I'll go ahead and accept this answer (because it is correct that gzfactory does what I asked for).

$\endgroup$
0
$\begingroup$

Gazebo Answers logo

Also, if you want to use Gazebo with ROS without using DRCSIM, you can easily create your own ROS enabled plugin. Here is a tutorial on how to do it.

Cheers, Andrei


Originally posted by AndreiHaidu with karma: 2108 on 2013-04-04

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Gazebo Answers logo

I went ahead and marked @scpeters' answer as correct, because it does answer my original question. The thing I left out of the original question was that I need to spawn URDF models (and would prefer not to convert them to SDF). @AndreiHaidu's answer inspired the solution I actually used, which was to modify drcsim's gazebo_ros_api_plugin to provide the spawning services. It turns out that the lines to provide the services were present, but not being compiled due to dependency issues that would arise when compiling drcsim. (I discovered later that I should have used the simulator_gazebo version of gazebo_ros_api_plugin, because it has some bug fixes that the drcsim version doesn't.) Then I was able to use the modified version of the plugin with the system version of Gazebo to spawn URDF models via ROS, though Gazebo is displaying one of the models 100 times smaller than it should be... (But that's another issue.)

If anyone wants details on what I did, leave a comment and I'll expand the answer.


Originally posted by Elizabeth C with karma: 33 on 2013-04-21

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.