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

Fix non-deterministic test failure in test_gravity_term #40

Closed traversaro closed 1 year ago

traversaro commented 1 year ago

This PR fixes the non-deterministic test failure discussed in https://github.com/conda-forge/staged-recipes/pull/21894#issuecomment-1535488061 and https://github.com/ami-iit/ADAM/pull/38 . The source of the non-determinism was the use of non-initialized memory, as a idyntree.bindings.Twist object was created, but never initialized to zero. In most of the cases their actual value was zero, but sometime its value was actually something else, resulting in a test failure. See the following code snippet for an example:

>>> import idyntree
>>> a = idyntree.bindings.Twist()
>>> a.toString()
'4.64577e-310 0 6.91004e-310  6.91004e-310 0 2.07508e-322 \n'
>>> a = idyntree.bindings.Twist.Zero()
>>> a.toString()
'0 0 0  0 0 0 \n'
Giulero commented 1 year ago

Thanks a lot @traversaro for spotting and solving this issue!