0
$\begingroup$

Rosanswers logo

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-


Originally posted by Robert Krug on ROS Answers with karma: 225 on 2012-02-22

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by DimitriProsser with karma: 11163 on 2012-02-22

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Robert Krug on 2012-02-23:
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!

$\endgroup$

Your Answer

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