robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
155 stars 65 forks source link

Fix bug preventing export of iDynTree::Model with non-zero axis offset to URDF and bump version to 12.3.1 #1188

Closed traversaro closed 3 weeks ago

traversaro commented 3 weeks ago

I noticed this today in https://github.com/icub-tech-iit/creo2urdf/issues/97#issuecomment-2163188586 .

Basically in iDynTree the joint axis can have any direction and offset, while for URDF the joint axis must pass through the child link frame origin. However, the check to ensure this in the URDF exported had a bug, as it checked the origin of the axis was 0,0,0, but it is perfectly fine for the axis to have a non-zero offset, as long as the axis still passes through the origin of the frame. For example, if you have an axis defined as (direction: [1,0,0], offset: [1,0,0]), that is ok for URDF as it passes through the origin, but it was rejected before this PR.

This PR fixes the problem by actually checking the distance between the axis (expressed in the child link frame) and the origin of the child link frame (that is simply [0 0 0]) is different from zero, rather then simply checking that the axis offset is different from zero.

Furthermore, tests have been added to ensure that the new check works as expected.

traversaro commented 3 weeks ago

It is interesting that we never found this problem in our use of the URDF exporter, fyi @francesco-romano .