Open isorrentino opened 2 years ago
Good point. This is a nasty effect of the fact that .FromPython
method is a function that returns a new instance of the type, instead of populating the instance on which it is called (as .fromMatlab
does). I am not sure why this happened back in time, but the quickest solution for your use case is to add a FromMatlab
overload for JointPosDoubleArray
, as done for example in https://github.com/robotology/idyntree/pull/959 for iDynTree::Position
.
An alternative may be to define a .FromPythonInPlace
method for iDynTree::VectorDynSize
(better name suggestions are welcome) that populate the existing vector instead of returning a new one (a bit like .fromMatlab
do), and then use this new method in JointPosDoubleArray
.
Here an example. If I run this code:
x_idyn
becomes aVectorDynSize
object. Maybe, this happens because theFromPython
function that is actually called is the one defined in https://github.com/robotology/idyntree/blob/163cff7899f7a660ed78fe550e4774553a4ced60/bindings/python/python.i#L184.