Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong type returned when calling FromPython function #999

Open
isorrentino opened this issue Jun 11, 2022 · 2 comments
Open

Wrong type returned when calling FromPython function #999

isorrentino opened this issue Jun 11, 2022 · 2 comments

Comments

@isorrentino
Copy link
Contributor

Here an example. If I run this code:

x_py = numpy.zeros(6)
x_idyn = idyn.JointPosDoubleArray(6)
x_idyn = x_idyn.FromPython(x_py)

x_idyn becomes a VectorDynSize object. Maybe, this happens because the FromPython function that is actually called is the one defined in

static iDynTree::VectorDynSize FromPython(double* in, int size) {
.

@traversaro
Copy link
Member

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 #959 for iDynTree::Position.

@traversaro
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants