scpeters-test / sdformat

Simulation Description Format (SDF) parser and description files.
http://sdformat.org
Other
1 stars 0 forks source link

Hard to set URDF model to static with multiple <gazebo> tags #197

Open scpeters-test opened 6 years ago

scpeters-test commented 6 years ago

Original report (archived issue) by Steve Peters (Bitbucket: Steven Peters).


@caguero and I discovered today that if you want to use <gazebo> to make a urdf model static, you might run into problems if you have multiple <gazebo> tags. For example, the following urdf will not be static after converting to sdf:

<?xml version="1.0" ?>
<robot name="static_test">

  <link name="world"/>
  <gazebo>
    <static>1</static>
  </gazebo>
  <gazebo/>

</robot>
$ gz sdf -p test/integration/static_test.urdf 
Warning [parser_urdf.cc:1115] multiple inconsistent <static> exists due to fixed joint reduction overwriting previous value [true] with [false].
<sdf version='1.6'>
  <model name='static_test'>
    <static>0</static>
  </model>
</sdf>

It gives a warning: "Warning [parser_urdf.cc:1115] multiple inconsistent exists due to fixed joint reduction overwriting previous value [true] with [false]."

I think the following code might fix the parsing for this specific model, relying on the fact that sdf models are not static by default, but it may have side-effects for other models.

diff -r 52b50d2823a67366ccbf17f9976aa36ed7cab4e5 src/parser_urdf.cc
--- a/src/parser_urdf.cc        Thu Oct 26 14:18:25 2017 -0700
+++ b/src/parser_urdf.cc        Wed Aug 29 17:43:43 2018 -0700
@@ -2346,8 +2346,6 @@
         // insert static flag
         if ((*ge)->setStaticFlag)
           AddKeyValue(_elem, "static", "true");
-        else
-          AddKeyValue(_elem, "static", "false");

         // copy extension containing blobs and without reference
         for (std::vector<TiXmlElementPtr>::iterator