0
$\begingroup$

Gazebo Answers logo

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


Originally posted by [email protected] on Gazebo Answers with karma: 21 on 2017-04-20

Post score: 1

$\endgroup$

2 Answers 2

0
$\begingroup$

Gazebo Answers logo

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.

Originally posted by winston with karma: 449 on 2017-04-21

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by [email protected] on 2017-04-21:
Thanks for your answer.

Comment by [email protected] on 2017-04-21:
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.

Comment by winston on 2017-04-23:
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.

Comment by winston on 2017-04-23:
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.

$\endgroup$
0
$\begingroup$

Gazebo Answers logo

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


Originally posted by iche033 with karma: 1018 on 2017-04-20

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by [email protected] on 2017-04-20:
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.

Comment by iche033 on 2017-04-20:
this may help: http://answers.ros.org/question/28557/how-can-i-use-the-c-program-to-add-delete-object-in-ros-gazebo/

Comment by [email protected] on 2017-04-21:
Thanks, really helpful. I will go through this page.

$\endgroup$

Your Answer

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