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

How do I spawn a urdf object programmatically?

asked 2011-11-20 13:46:30 -0500

Raskolnikov gravatar image

updated 2014-11-22 17:05:15 -0500

ngrennan gravatar image

I take a .pcd file as input and process the pointcloud using pcl. I then want to spawn an object in Gazebo using the results of that processing so that I can simulate the manipulation of that object with a pr2. Is there a programmatic way to do this , i.e. using c++.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-11-21 02:52:52 -0500

updated 2011-11-21 02:53:59 -0500

When you spawn it in a launch file it works like this:

 <node name="spawned_object_name" pkg="gazebo" type="spawn_model" 
 args="-urdf -file $(find rospackagename)/path/to/file.urdf -model 
 object_name_from_gazebo_perspective  -x 0.50 -y 0.05 -z 0.65" 
 respawn="false" output="screen" />

If you look at

it tells you that there is also a ROS service gazebo/spawn_model which you can call programmatically through a ROS message - this seems like the right way to do it.

Here is the documentation of the service:

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2011-11-20 13:46:30 -0500

Seen: 2,871 times

Last updated: Nov 21 '11