0
$\begingroup$

Rosanswers logo

How can I spawn a URDF into a custom Gazebo world, preferably using a launch file?

My task is to launch my custom Gazebo world which has a DEM of Mongolia. I also have to spawn a URDF of a robot into the same Gezebo instance.

For the DEM, I followed this tutorial. Which worked well for me. But then I tried the following command to try spawning my robot:

ubuntu@ubuntu:~/catkin2_ws/src/my-robot$ rosrun gazebo_ros spawn_model -file urdf/01-myfirst.urdf -urdf -z 1 -model my_test

The terminal only shows the following output and nothing else happens:

SpawnModel script started
[INFO] [1511782992.386535, 0.000000]: Loading model XML from file
[INFO] [1511782992.388399, 0.000000]: Waiting for service /gazebo/spawn_urdf_model

When I stop the terminal, i:e Ctrl + C, I get the following output:

>     ^CTraceback (most recent call last):
>       File "/opt/ros/kinetic/lib/gazebo_ros/spawn_model",
> line 313, in <module>
>         sm.callSpawnService()
>       File "/opt/ros/kinetic/lib/gazebo_ros/spawn_model",
> line 271, in callSpawnService
>         initial_pose, self.reference_frame,
> self.gazebo_namespace)
>       File "/opt/ros/kinetic/lib/python2.7/dist-packages/gazebo_ros/gazebo_interface.py",
> line 28, in spawn_urdf_model_client
>         rospy.wait_for_service(gazebo_namespace+'/spawn_urdf_model')
>       File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py",
> line 159, in wait_for_service
>         raise ROSInterruptException("rospy
> shutdown")
>     rospy.exceptions.ROSInterruptException:
> rospy shutdown

Can anyone help me resolve this issue, please?

My package has the following structure:

.
├── CMakeLists.txt
├── launch
│   └── mongolia.launch
├── mongolia_129.dem
├── mongolia.world
├── package.xml
└── urdf
    └── 01-myfirst.urdf

**PS: **

This work fine if I execute:

ubuntu@ubuntu:~/catkin2_ws/src/my-robot$ roslaunch gazebo_ros empty_world.launch

Originally posted by sisko on ROS Answers with karma: 247 on 2017-11-27

Post score: 3


Original comments

Comment by sisko on 2017-11-28:
Thank you so much. That's what I was missing all along

Comment by jarvisschultz on 2017-11-28:
Great... I converted my comment to an answer so that this question will show up as having an answer. It would be great if you could accept the answer.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Did you also run rosrun gazebo_ros gazebo in a separate terminal? That node should provide the /gazebo/spawn_urdf_model service the spawn_model node is waiting on. Note this node is also started in the empty_world.launch launch file.


Originally posted by jarvisschultz with karma: 9031 on 2017-11-27

This answer was ACCEPTED on the original site

Post score: 6

$\endgroup$

Your Answer

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