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

Fake links gets transformed in actual links with non-zero mass and inertia #19

Open
traversaro opened this issue Feb 22, 2022 · 3 comments

Comments

@traversaro
Copy link
Member

In the context of URDF files, "fake" links (i.e. links attached to their parent with a fixed joint and without any inertial tag) are commonly used to represent frames, as no "frame" concept is present in URDF (see https://discourse.ros.org/t/urdf-ng-link-and-frame-concepts/56).

This is possible as the URDF specification (http://wiki.ros.org/urdf/XML/link) clearly specify that for the inertial element the following hold:

(optional: defaults to a zero mass and zero inertia if not specified)

urdf-modifiers however does not seem to respect this, and expands "fake" links to links with unit mass and unit inertia.

Minimal Reproducible Example

In this example, we have a simple model with a real link and a fake link. If this is loaded and saved back to file when using urdf-modifiers, the mass of the model is duplicated.

How to run:

git clone https://gist.github.com/traversaro/b251019c117c14faee9d9808ac46600b
cd b251019c117c14faee9d9808ac46600b
python test.py

test.py:

from urdfModifiers.core.linkModifier import LinkModifier
from urdfModifiers.core.jointModifier import JointModifier
from urdfModifiers.core.modification import Modification
from urdfModifiers.utils import *

urdf_path ="./model_with_fake_links.urdf"
output_file = "./model_with_fake_links_converted.urdf"
dummy_file = 'no_gazebo_plugins.urdf'

robot, gazebo_plugin_text = utils.load_robot_and_gazebo_plugins(urdf_path,dummy_file)
utils.write_urdf_to_file(robot, output_file, gazebo_plugin_text)

model_with_fake_links.py :

<?xml version='1.0' encoding='UTF-8'?>
<robot name="modelWithFakeLinks">
    <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="fakeLinkFixedJoint" type="fixed">
        <origin xyz="0 0 0" rpy="0 0 0" />
        <axis xyz="0 0 0" />
        <parent link="link1" />
        <child link="fakeLink" />
    </joint>    
    <link name="fakeLink"/>
</robot>

After running the script, the model (model_with_fake_links_converted.urdf) becames:

<?xml version='1.0' encoding='UTF-8'?>
<robot name="modelWithFakeLinks">
  <link name="link1">
    <inertial>
      <origin xyz="0.0 0.0 0.0" rpy="0.0 -0.0 0.0"/>
      <mass value="1.0"/>
      <inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01"/>
    </inertial>
  </link>
  <link name="fakeLink">
    <inertial>
      <origin xyz="0.0 0.0 0.0" rpy="0.0 -0.0 0.0"/>
      <mass value="1.0"/>
      <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
  </link>
  <joint name="fakeLinkFixedJoint" type="fixed">
    <parent link="link1"/>
    <child link="fakeLink"/>
    <axis xyz="nan nan nan"/>
    <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
  </joint>
</robot>
@traversaro
Copy link
Member Author

I am afraid that this bug is actually in urdpy . If this is the case, the problem is that urdfpy does not seems to be really responsive to upstream PRs, so once we have a fix in urdfpy we may need to understand how to handle this.

@traversaro
Copy link
Member Author

fyi @GrmanRodriguez @AlexAntn @Nicogene @CarlottaSartore @fabiodinatale

@CarlottaSartore
Copy link
Contributor

C.C. @lrapetti @mebbaid

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

2 participants