robotology / idyntree

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

Add export to urdf of joint dynamics: damping and static friction coefficients #1094

Closed mfussi66 closed 10 months ago

mfussi66 commented 10 months ago

This PR aims to expand the Joints objects (Fixed, Revolute, Prismatic, IJoint) to support dynamic parameters present in URDF models. These parameters are damping coefficient (N*s/m for prismatic and N*m*s/rad for revolute) and static friction coefficient (N for prismatic and N*m for revolute) . The parameters can be imported from a urdf file or exported into one.

cc @traversaro @Nicogene

traversaro commented 10 months ago

Thanks a lot for this work! I want to comment a bit in depth in the PR, but before of that, it seems that there are a few memory-related error catched by the valgrind tests:

2023-08-30T14:20:08.1447826Z Model loaded from /__w/idyntree/idyntree/src/tests/data/iCubGenova02.urdf
2023-08-30T14:20:08.1448051Z ==19584== Conditional jump or move depends on uninitialised value(s)
2023-08-30T14:20:08.1448791Z ==19584==    at 0x487273D: iDynTree::exportJoint(iDynTree::IJoint const*, iDynTree::Link const*, iDynTree::Link const*, iDynTree::Model const&, _xmlNode*) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1449626Z ==19584==    by 0x48744DB: iDynTree::URDFStringFromModel(iDynTree::Model const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, iDynTree::ModelExporterOptions) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1450534Z ==19584==    by 0x486E0A0: iDynTree::ModelExporter::exportModelToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1450972Z ==19584==    by 0x10ED75: checkImportExportURDF(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /__w/idyntree/idyntree/build/bin/ModelExporterUnitTest)
2023-08-30T14:20:08.1451213Z ==19584==    by 0x10D586: main (in /__w/idyntree/idyntree/build/bin/ModelExporterUnitTest)
2023-08-30T14:20:08.1451308Z ==19584== 
2023-08-30T14:20:08.1451521Z ==19584== Conditional jump or move depends on uninitialised value(s)
2023-08-30T14:20:08.1452209Z ==19584==    at 0x4872765: iDynTree::exportJoint(iDynTree::IJoint const*, iDynTree::Link const*, iDynTree::Link const*, iDynTree::Model const&, _xmlNode*) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1453029Z ==19584==    by 0x48744DB: iDynTree::URDFStringFromModel(iDynTree::Model const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, iDynTree::ModelExporterOptions) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1454068Z ==19584==    by 0x486E0A0: iDynTree::ModelExporter::exportModelToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1454490Z ==19584==    by 0x10ED75: checkImportExportURDF(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /__w/idyntree/idyntree/build/bin/ModelExporterUnitTest)
2023-08-30T14:20:08.1454731Z ==19584==    by 0x10D586: main (in /__w/idyntree/idyntree/build/bin/ModelExporterUnitTest)
2023-08-30T14:20:08.1454824Z ==19584== 
2023-08-30T14:20:08.1455040Z ==19584== Conditional jump or move depends on uninitialised value(s)
2023-08-30T14:20:08.1455475Z ==19584==    at 0x488DFCD: idyntree_private_fpconv_dtoa (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1456267Z ==19584==    by 0x487277A: iDynTree::exportJoint(iDynTree::IJoint const*, iDynTree::Link const*, iDynTree::Link const*, iDynTree::Model const&, _xmlNode*) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1457096Z ==19584==    by 0x48744DB: iDynTree::URDFStringFromModel(iDynTree::Model const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, iDynTree::ModelExporterOptions) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1458097Z ==19584==    by 0x486E0A0: iDynTree::ModelExporter::exportModelToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1458639Z ==19584==    by 0x10ED75: checkImportExportURDF(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /__w/idyntree/idyntree/build/bin/ModelExporterUnitTest)
2023-08-30T14:20:08.1458886Z ==19584==    by 0x10D586: main (in /__w/idyntree/idyntree/build/bin/ModelExporterUnitTest)
2023-08-30T14:20:08.1458988Z ==19584== 
2023-08-30T14:20:08.1459204Z ==19584== Conditional jump or move depends on uninitialised value(s)
2023-08-30T14:20:08.1459647Z ==19584==    at 0x488DFEE: idyntree_private_fpconv_dtoa (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1460339Z ==19584==    by 0x487277A: iDynTree::exportJoint(iDynTree::IJoint const*, iDynTree::Link const*, iDynTree::Link const*, iDynTree::Model const&, _xmlNode*) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1461178Z ==19584==    by 0x48744DB: iDynTree::URDFStringFromModel(iDynTree::Model const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, iDynTree::ModelExporterOptions) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1462086Z ==19584==    by 0x486E0A0: iDynTree::ModelExporter::exportModelToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /__w/idyntree/idyntree/build/lib/libidyntree-modelio.so)
2023-08-30T14:20:08.1462512Z ==19584==    by 0x10ED75: checkImportExportURDF(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /__w/idyntree/idyntree/build/bin/ModelExporterUnitTest)
2023-08-30T14:20:08.1462755Z ==19584==    by 0x10D586: main (in /__w/idyntree/idyntree/build/bin/ModelExporterUnitTest)

Can you check them? To get more informative errors, you can compile locally in Debug model and so you will get the line numbers related to this.

traversaro commented 10 months ago

@mfussi66 sorry, I broke your branch with the commit https://github.com/mfussi66/idyntree/commit/8dfc3f99532003f2152390ac514a495871f8c2a8, but for some reason I couldn't easy create a PR out of it. However, it implements (in the interface) what we discuss, if you could modify the rest of the PR to be aligned it would be great, thanks!

traversaro commented 10 months ago

This is still not ready for review, but probably @francesco-romano may be interested in this.

mfussi66 commented 10 months ago

Seems like there are errors related to fortran libraries:

Matlab tests:

{Error using iDynTree.Position (line 10)
Invalid MEX-file '/home/runner/work/idyntree/idyntree/build/lib/iDynTreeMEX.mexa64': /usr/local/MATLAB/R2020b/bin/glnxa64/../../sys/os/glnxa64/libgfortran.so.5: version
`GFORTRAN_10' not found (required by /usr/share/miniconda3/envs/test/lib/./libspral.so)

Debian tests:

2023-08-31T15:04:08.5475268Z gmake[2]: *** No rule to make target '/usr/lib/gcc/x86_64-linux-gnu/12/libgfortran.so', needed by 'bin/iKinConsistencyTest'.  Stop.

Are they an issue for this PR?

traversaro commented 10 months ago

Seems like there are errors related to fortran libraries:

Matlab tests:

{�Error using iDynTree.Position (line 10)
Invalid MEX-file '/home/runner/work/idyntree/idyntree/build/lib/iDynTreeMEX.mexa64': /usr/local/MATLAB/R2020b/bin/glnxa64/../../sys/os/glnxa64/libgfortran.so.5: version
`GFORTRAN_10' not found (required by /usr/share/miniconda3/envs/test/lib/./libspral.so)

Debian tests:

2023-08-31T15:04:08.5475268Z gmake[2]: *** No rule to make target '/usr/lib/gcc/x86_64-linux-gnu/12/libgfortran.so', needed by 'bin/iKinConsistencyTest'.  Stop.

Are they an issue for this PR?

No, please ignore, thanks.

traversaro commented 10 months ago

Thanks @mfussi66 !