Ask Your Question
0

/gazebo/spawn_urdf_model service fails

asked 2012-02-22 04:58:11 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hi,

In ROS electric, I want to spawn models in gazebo in a programmatic way via the /gazebo/spawn_urdf_model service. So I wrote a node implementing an according client but when I try to load models I get the following error from Gazebo: 'SpawnModel: Failure - model format is not URDF (nor COLLADA).' This also happens when I try calling the service from a terminal, e.g., rosservice call /gazebo/spawn_urdf_model '{model_name: "coke_can", model_xml: "/opt/ros/electric/stacks/simulator_gazebo/gazebo_worlds/objects/coke_can.urdf", robot_namespace: "/foo", initial_pose: {position: {x: 0, y: 0, z: 0}, orientation: {x: 0, y: 0, z: 0, w: 1}}, reference_frame: "world"}'. Trying to spawn the same object via rosrun gazebo spawn_model ... works perfectly fine. The error occurs in /gazebo/src/gazeboros.cpp in the method 'bool IsURDF(std::string model_xml)'. The TiXmlDocument which is parsed there always seems to be empty. Am I doing something wrong or is this a bug?

Thanks, -Robert-

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-02-22 06:57:00 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

You have to literally serialize the urdf file into a data structure. The service does not ask for the file path of the urdf, but rather the actual urdf. You might want to use the urdf parser.

I'm not sure if this works in C++ or not, but in Python, I simply read the entire contents of a urdf file directly into a string variable, and that works just fine.

edit flag offensive delete link more

Comments

Indeed, also in C++ reading the urdf file contents into a string and use this string in the SpawnModel service works. Thanks for your help!

Robert Krug gravatar image Robert Krug  ( 2012-02-23 01:43:54 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-02-22 04:58:11 -0500

Seen: 3,055 times

Last updated: Feb 22 '12