SDF readFile not parsing world file [closed]

asked 2018-03-20 09:19:57 -0500

dhindhimathai gravatar image

I am using ROS Indigo with Ubuntu 14.04.

I need to parse the elements of a file using sdf::readFile. The file is as follows:

<?xml version="1.0" ?>
<sdf version="1.4">
  <world name="default">

    <model name="box">
    <pose>1.4 0.8 0.14 0 0 0</pose>
    <link name='link_box'>
        <pose>0 0 0 0 0 0</pose>
        <collision name="collision_box">
            <pose>0 0 0 0 0 0</pose>
                    <size>1 2 1.3</size>

            <visual name="visual_box">
                    <size>1 2 1.3</size>



In a portion of my C++ code I try to parse the content of the world file as follows:

// Read the sdf
sdf::SDFPtr sdfParsed(new sdf::SDF());

const std::string sdfStringPath(argv[1]);

assert(sdf::readFile(sdfStringPath, sdfParsed));

But this does not seem to function as expected because if I try to print sdfParsed with

cout << "THE PARSED SDF IS: " << sdfParsed->ToString() << endl;

the output is the following:

THE PARSED SDF IS: <?xml version='1.0'?> <sdf version='1.5'/>

The argv[1] is clearly the path to the above mentioned .world file. What's wrong with my code?

Thanks in advance.

edit retag flag offensive reopen merge delete

Closed for the following reason Gazebo Question: The Gazebo community prefers to answer questions at: by gvdhoorn
close date 2018-03-20 09:50:33.666206


While not immediately about Gazebo itself, sdf is Gazebo's file format for simulations and the Gazebo devs are its developers. I recommend you post your question on their support forum as that will probably lead to better answers, faster.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-20 09:51:27 -0500 )edit

Please do post a link to your question on Gazebo Answers, so we keep things connected.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-20 09:51:43 -0500 )edit