SDF readFile not parsing world file
I am using ROS Indigo with Ubuntu 14.04.
I need to parse the elements of a simple_environment.world file using sdf::readFile
. The simple_environment.world file is as follows:
<?xml version="1.0" ?>
<sdf version="1.4">
<world name="default">
<include>
<uri>model://ground_plane</uri>
</include>
<include>
<uri>model://sun</uri>
</include>
<model name="box">
<pose>1.4 0.8 0.14 0 0 0</pose>
<static>true</static>
<link name='link_box'>
<pose>0 0 0 0 0 0</pose>
<collision name="collision_box">
<pose>0 0 0 0 0 0</pose>
<geometry>
<box>
<size>1 2 1.3</size>
</box>
</geometry>
</collision>
<visual name="visual_box">
<geometry>
<box>
<size>1 2 1.3</size>
</box>
</geometry>
</visual>
<self_collide>0</self_collide>
<gravity>1</gravity>
</link>
</model>
</world>
</sdf>
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());
sdf::init(sdfParsed);
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.