urdf reader segfault condition

Issue #57 resolved
Anonymous created an issue

It looks like if you have a robot that is just a single floating body(like maybe a quadcopter or a body with thrusters) the urdf reader segfaults. An example urdf would be,

<robot name="test_urdf" xmlns:xacro="http://www.ros.org/wiki/xacro">
  <link name="root_body">
    <inertial>
      <mass value="1"/>
      <origin rpy="0 0 0" xyz="0.0 0.0 0.0"/>
      <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
  </link>
</robot>

It segfaults bc there are no child joints. Think this is the offending line,unsigned int joint_idx = joint_index_stack.top();

Comments (2)

  1. ffusco

    I think I found another issue that causes the URDF reader to crash. The problem arises when multiple joints are added as children of a root link without inertial properties. From what I can see, the error in the URDF reader should be given by the line

    if (urdf_parent->name != "base_joint" && rbdl_model->mBodies.size() != 1)
    

    with the hard-coded "base_joint" name causing the troubles. I guess it should be replaced by root->name? I tried to test it with this simple urdf:

    <robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="test">
      <link name="world"/>
    
      <joint name="jointA" type="continuous">
        <parent link="world"/>
        <child link="linkA"/>
      </joint>
    
      <link name="linkA"/>
    
      <joint name="jointB" type="continuous">
        <parent link="world"/>
        <child link="linkB"/>
      </joint>
    
      <link name="linkB"/>
    </robot>
    

    As the root link "world" does not contain inertial information, it is simply skipped during the construction of a model. Later, when trying to add jointB, its parent (world) is not recognized as the root and the parent body id is looked for. However, as it was skipped before, we get std::numeric_limits<unsigned int>::max() as parent body id, and later a segmentation fault.

  2. Log in to comment