Gazebo | Ignition | Community
Ask Your Question
1

How to remove or respawn robots during the simulation?

asked 2017-04-20 02:45:21 -0600

jasonwang538@gmail.com gravatar image

Hi everyone

I am a new gazebo user. Currently, I am implementing an algorithm by using Ros platform with Gazebo simulator. I will use a group of robot (at least 10 hector quadrotors) for the simulations. And under some certains conditions, the robot need to be removed or respawned during the simulation.

I use .cpp file as a rosnode to run the controllers (algorithm) for all robots. Does anyone know how to realize this dynamic removal or respawn through .cpp file? or .launch file?

Thank you very much

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-04-21 09:07:29 -0600

winston gravatar image

There are two methods in general:

  1. You could use a ROS service call as @iche033 has said. But you need to install gazebo_ros package first.
  2. You could use Gazebo's built-in functions. There are a couple of functions which can insert or delete a model in gazebo::physics::World Class (link). For example, RemoveModel (const std::string &_name) to remove a model or InsertModelFile (const std::string &_sdfFilename) to insert a model.
edit flag offensive delete link more

Comments

Thanks for your answer.

jasonwang538@gmail.com gravatar imagejasonwang538@gmail.com ( 2017-04-21 11:02:27 -0600 )edit

Hi, sorry for asking another issue. I use a .xacro file for descripting the robot instead of the .urdf format. In terms of gazebo_msgs/SpawnModel message type, for the field of model_xml, can I still use .xacro file? Or I need to convert .xacro into .urdf then assign it to the model_xml field? Because I do not know how to convert .xacro to .urdf in c++ file.

jasonwang538@gmail.com gravatar imagejasonwang538@gmail.com ( 2017-04-21 11:40:11 -0600 )edit

I am not sure but I think .xacro should be OK. Why not have a try? BTW, if you have fond the satisfied answer to your question, please tick it as the best answer so that other people who may have the same problem could find out the answer as fast as possible.

winston gravatar imagewinston ( 2017-04-23 23:39:48 -0600 )edit

I am not sure but I think .xacro should be OK. Why not have a try? BTW, if you have found the satisfied answer to your question, please tick it as the best answer so that other people who may have the same problem could find out the answer as fast as possible.

winston gravatar imagewinston ( 2017-04-23 23:40:05 -0600 )edit
1

answered 2017-04-20 11:27:40 -0600

iche033 gravatar image

you can probably just use ros services to spawn and delete models. See this tutorial

edit flag offensive delete link more

Comments

Thank you very much for telling me this. But, could you tell me a little bit more about this? I use .cpp file as a executable for controlling the robot. But I do not know which Gazebo API can release this. Do you know some avaible class or APIs? I am grateful for any reply from you.

jasonwang538@gmail.com gravatar imagejasonwang538@gmail.com ( 2017-04-20 12:22:47 -0600 )edit

Thanks, really helpful. I will go through this page.

jasonwang538@gmail.com gravatar imagejasonwang538@gmail.com ( 2017-04-21 10:38:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-04-20 02:45:21 -0600

Seen: 6,384 times

Last updated: Apr 21 '17