Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URDF export code exports malformed URDF models with limit tags but no velocity or effort attributes #955

Open
traversaro opened this issue Jan 5, 2022 · 5 comments

Comments

@traversaro
Copy link
Member

traversaro commented Jan 5, 2022

According to the URDF spec (http://wiki.ros.org/urdf/XML/joint), if a joint has a limit tag, then the lower and upper attributes are optional, but the effort and velocity attributes are not exported.

To clarify the problem, if one has the following URDF model named twoLinks.urdf:

<robot name="twoLinks">
    <link name="link1">
        <inertial>
            <mass value="1" />
            <inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01" />
        </inertial>
    </link>
    <joint name="joint_1_2" type="revolute">
        <origin xyz="1 0 0" rpy="0 -0 0" />
        <axis xyz="0 0 1" />
        <parent link="link1" />
        <child link="link2" />
        <limit effort="1.56666666667" lower="-0.698131700798" upper="0.698131700798" velocity="21.2930168743"/>
    </joint>
    <link name="link2">
        <inertial>
            <mass value="1" />
            <inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01" />
            <origin xyz="1 0 0" rpy="0 -0 0" />
        </inertial>
    </link>
</robot>

and it runs it in the idyntree-model-simplify-shapes:

idyntree-model-simplify-shapes -m twoLinks.urdf -o twoLinksModified.urdf

the resulting twoLinksModified.urdf file is:

<?xml version="1.0"?>
<robot name="iDynTreeURDFModelExportModelName">
  <link name="link1">
    <inertial>
      <mass value="1"/>
      <origin xyz="0 0 0" rpy="0 -0 0"/>
      <inertia ixx="0.01" ixy="0" ixz="0" iyy="0.01" iyz="0" izz="0.01"/>
    </inertial>
  </link>
  <joint name="joint_1_2" type="revolute">
    <origin xyz="1 0 0" rpy="0 -0 0"/>
    <axis xyz="0 0 1"/>
    <parent link="link1"/>
    <child link="link2"/>
    <limit lower="-0.698131700798" upper="0.698131700798"/>
  </joint>
  <link name="link2">
    <inertial>
      <mass value="1"/>
      <origin xyz="1 0 0" rpy="0 -0 0"/>
      <inertia ixx="0.01" ixy="0" ixz="0" iyy="0.010000000000000009" iyz="0" izz="0.010000000000000009"/>
    </inertial>
  </link>
</robot>

If we then check the two models with the check_urdf utility provided by the urdfdom library, this is the output:

(idyntree) C:\src\idyntree\src\tests\data>check_urdf twoLinks.urdf
robot name is: twoLinks
---------- Successfully Parsed XML ---------------
root Link: link1 has 1 child(ren)
    child(1):  link2

(idyntree) C:\src\idyntree\src\tests\data>check_urdf twoLinksModified.urdf
Error:   joint limit: no effort
         at line 167 in D:\bld\urdfdom_1623959814707\work\urdf_parser\src\joint.cpp
Error:   Could not parse limit element for joint [joint_1_2]
         at line 565 in D:\bld\urdfdom_1623959814707\work\urdf_parser\src\joint.cpp
Error:   joint xml is not initialized correctly
         at line 206 in D:\bld\urdfdom_1623959814707\work\urdf_parser\src\model.cpp
ERROR: Model Parsing the xml failed
@traversaro
Copy link
Member Author

@traversaro
Copy link
Member Author

This is particularly problematic as it prevents to load any URDF file generated by iDynTree by any library that uses urdfdom to load URDF files.

@traversaro
Copy link
Member Author

traversaro commented Jan 5, 2022

For the time being, a quick fix to at least being able to create a release of iDynTree that creates valid URDFs is to just add really high limits (like 1e9) for velocity and effort attributes, i.e. after

xmlNewProp(limit_xml, BAD_CAST "upper", BAD_CAST bufStr.c_str());
the lines:

        // Workaround for https://github.com/robotology/idyntree/issues/955
        double reallyHighLimit = 1e9;
        ok = ok && doubleToStringWithClassicLocale(reallyHighLimit, bufStr);
        xmlNewProp(limit_xml, BAD_CAST "effort", BAD_CAST bufStr.c_str());
        ok = ok && doubleToStringWithClassicLocale(reallyHighLimit, bufStr);
        xmlNewProp(limit_xml, BAD_CAST "velocity", BAD_CAST bufStr.c_str());

@traversaro
Copy link
Member Author

@Andrea8Testa given that you have a commit that solves this in https://github.com/Andrea8Testa/idyntree/commit/6ac5ad63af33d5290ff20c75bcbc66f10fd2adec , can you open a PR for this? If necessary I can help you doing this, otherwise you can just follow GitHub docs in https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request , thanks!

@traversaro
Copy link
Member Author

A proper solution is tracked in #958 .

traversaro added a commit that referenced this issue Jan 10, 2022
Co-authored-by: Silvio Traversaro <silvio@traversaro.it>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant