ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to remove and respawn robot

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

jasonwang538@gmail.com 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
0

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:

http://gazebosim.org/tutorials?tut=ro...

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

Comments

Thanks for telling me this

jasonwang538@gmail.com gravatar image jasonwang538@gmail.com  ( 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.

jasonwang538@gmail.com gravatar image jasonwang538@gmail.com  ( 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

Question Tools

1 follower

Stats

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

Seen: 1,352 times

Last updated: Apr 20 '17