ami-iit / adam

adam implements a collection of algorithms for calculating rigid-body dynamics in Jax, CasADi, PyTorch, and Numpy.
https://adam-docs.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
131 stars 20 forks source link

Set inertial origin to zero when is none in the urdf #45

Closed Giulero closed 1 year ago

Giulero commented 1 year ago

Sometimes in the .urdf, a link can contain the inertial field (in such a case, we call it link, opposite to frame, which doesn't have inertial) without the origin, e.g.:

    <inertial>
      <mass value="0.06"/>
      <inertia ixx="1.6854e-05" ixy="0.0" ixz="0.0" iyy="1.6854e-05" iyz="0.0" izz="1.6854e-05"/>
    </inertial>

In this case, an error arises when StdLink.spatial_inertial() or StdLink.homogeneus() since link.inertial.origin is None.

This PR should fix this issue by assigning link.inertial.origin.xyz = [0,0,0] and link.inertial.origin.rpy = [0,0,0].

@traversaro do you think that this case can be managed in this way?

traversaro commented 1 year ago

@traversaro do you think that this case can be managed in this way?

If you check the URDF specification (http://wiki.ros.org/urdf/XML/link), it is stated:

(optional: defaults to a zero mass and zero inertia if not specified) The link’s mass, position of its center of mass, and its central inertia properties. (optional: defaults to identity if not specified)

So, I think the fix is indeed correct and conformant to URDF specification (it could even make sense to report it to the urdf_parser_py repo, as it could make sense that this substitution is done by urdf_parser_py itself.

Giulero commented 1 year ago

Thanks a lot @traversaro!