Bug in URDF to SDF convertion for Boolean tags in Gazebo 9

Issue #2512 invalid
Petro Shmigelskyi created an issue

When load robot URDF to gazebo Boolean values in <plugin> tag are converted to Integers

Part of input URDF:

  <gazebo>
    <plugin filename="libgazebo_ros_diff_drive.so" name="pioneer_lx_differential_drive_controller">
      <alwaysOn>true</alwaysOn>
      <updateRate>100</updateRate>
      <leftJoint>pioneer_lx_l_wheel_joint</leftJoint>
      <rightJoint>pioneer_lx_r_wheel_joint</rightJoint>
      <robotBaseFrame>pioneer_lx_base_link</robotBaseFrame>
      <wheelSeparation>0.4</wheelSeparation>
      <wheelDiameter>0.2</wheelDiameter>
      <wheelTorque>25</wheelTorque>
      <wheelAcceleration>0</wheelAcceleration>
      <legacyMode>false</legacyMode>
    </plugin>
  </gazebo>

Loading to gazebo yields warnings "<tag_name> must be either true or false" and values are not loaded.

Part of resulting SDF:

    <plugin name='pioneer_lx_differential_drive_controller' filename='libgazebo_ros_diff_drive.so'>
      <alwaysOn>1</alwaysOn>
      <updateRate>100</updateRate>
      <leftJoint>pioneer_lx_l_wheel_joint</leftJoint>
      <rightJoint>pioneer_lx_r_wheel_joint</rightJoint>
      <robotBaseFrame>pioneer_lx_base_link</robotBaseFrame>
      <wheelSeparation>0.4</wheelSeparation>
      <wheelDiameter>0.2</wheelDiameter>
      <wheelTorque>25</wheelTorque>
      <wheelAcceleration>0</wheelAcceleration>
      <legacyMode>0</legacyMode>
    </plugin>

Comments (5)

  1. Petro Shmigelskyi reporter

    gazebo_ros_utils reeds values from model it receive in input (SDF). It this stage boolean values are already replaced with integer. Seems bug is in URDF-to-SDF conversion stage.

    I receive incorrect SDF using command:

    gz sdf -p model.urdf > model.sdf
    
  2. Petro Shmigelskyi reporter

    This problem appeared to me cos I used Gazebo9 with ROS kinetic. For ROS melodic it is fixed in gazebo_ros_utils by comparing Integers and Booleand

    if(boost::iequals(value, std::string("true")) || boost::iequals(value, std::string("1")))
    
  3. Louise Poubel

    I believe the problem would be better solved if gazebo_ros_utils used Get<bool> instead of Get<std::string>. That function should handle all cases, including uppercase, see here.

  4. Log in to comment