Ask Your Question
0

/gazebo/spawn_urdf_model service fails

asked Feb 22

this post is marked as community wiki

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

updated Feb 22

Robert Krug gravatar image Robert Krug
54 9

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-

delete close flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered Feb 22

this post is marked as community wiki

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

updated Feb 22

DimitriProsser gravatar image DimitriProsser flag of United States
6817 23 59 126

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.

link delete flag offensive edit

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 (Feb 23)edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Follow

subscribe to rss feed

Stats

Asked: Feb 22

Seen: 46 times

Last updated: Feb 22

Related questions