Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

SDF readFile not parsing world file

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.