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

Revision history [back]

click to hide/show revision 1
initial version

The easiest way to dynamically spawn a model from your code is to call the spawn_model ROS service offered by gazebo_ros, which essentially is the same what the spawn_model node does internally. I.e. instead of running the spawn_model node, you call the spawn_model service.

You can see here how the corresponding service interface is defined. Use rosservice list to find the correct name of the service instance while you have your Gazebo instance running.

Tutorials for writing a service client (which is very easy and similar to writing a ROS publisher) can be found here: C++ service client tutorial
Python service client tutorial

The easiest way to dynamically spawn a model from your code is to call the spawn_model ROS service offered by gazebo_ros, which essentially is the same what the spawn_model node does internally. I.e. instead of running the spawn_model node, you call the spawn_model service.

You can see here how the corresponding service interface is defined. Use rosservice list to find the correct name of the service instance while you have your Gazebo instance running.

Tutorials for writing a service client (which is very easy and similar to writing a ROS publisher) can be found here: here:
C++ service client tutorial
Python service client tutorial