Ask Your Question

How to remove and respawn robot

asked 2017-04-20 08:04:56 -0500 gravatar image

Hi everyone

I am a new user of ROS with Gazebo 5. I am wondering how to remove and respawn hector quadrotors during the simulation. More specifically, robots should be removed or respawned when certain conditions are met.

Thank you very much

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-20 20:20:59 -0500

Geoff gravatar image

Gazebo, when run through ROS, provides a ROS API for accessing and controlling the simulation. There is a good tutorial available in the Gazebo documentation:

Specifically for creating and destroying robots, you can use the spawn_model and delete_model services. If you want to do this based on conditions, you should create a node to manage your simulated robots. It should these services and decide when to call them.

You can also use the spawn_model node in the gazebo_ros package to spawn models from a launch file. For example:

<node name="spawn_hector" pkg="gazebo_ros" type="spawn_model" args="-file hector.srdf -sdf -model hector_the_quadrotor"/>

This is an alternative way to set up your simulation, but I think that if you are going to manage them as the simulation runs, then the node responsible for managing the models should also be responsible for the initial creation of them.

edit flag offensive delete link more


Thanks for telling me this gravatar image  ( 2017-04-21 11:02:21 -0500 )edit

Hi, Geoff

Sorry to bother you again. I have 2 questions.

  1. I use gazebo 5 with ROS jade. I cannot find service /gazebo/spawn_urdf_model. Should I install something?

  2. Which .hh file should I include? I cannot find that header file

Thank you very much. gravatar image  ( 2017-04-21 14:05:51 -0500 )edit

The gazebo_msgs package contains the service definitions. You will need to include the header files for the SpawnModel and DeleteModel messages (e.g. gazebo_msgs/SpawnModel.h).

By "cannot find service..." do you mean that the service is not visible in rosservice list?

Geoff gravatar image Geoff  ( 2017-04-23 20:01:28 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-04-20 08:04:56 -0500

Seen: 581 times

Last updated: Apr 20 '17