stack-of-tasks / pinocchio

A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
http://stack-of-tasks.github.io/pinocchio/
BSD 2-Clause "Simplified" License
1.8k stars 379 forks source link

[Bindings] container::aligned_vector<Force> in python #1016

Closed NoelieRamuzat closed 4 years ago

NoelieRamuzat commented 4 years ago

Hi ! I would like to use the rnea algorithm with the external forces in python. The binding of the method rnea(Model, Data, Configuration q, Velocity v, Acceleration a, External forces f) does exist. But the external forces should be expressed as a container::aligned_vector<Force> vector, which is an object of pinocchio. I have seen that there is a binding in std-aligned-vector.hpp. But I don't know how to use it.

In python I have access to pin.utils.pin.StdVec_Force, should I use it ? My external forces are expressed as a numpy.ndarray, how can I convert it ?

Thank you very much for your time !

jcarpent commented 4 years ago

You should indeed use pin.StdVec_Force which has the same API than a list in Python. Then, you should fill this pin.StdVec_Forcewith all the external forces for each joint expressed in the local frame of joint.

jcarpent commented 4 years ago

One thing to do is to extend the current bindings with functions taking Python list as input and converting them to std::vector.

NoelieRamuzat commented 4 years ago

Hi sorry for the delay, It is working well thank you ! I've created a pin.Forceobject for each forces I had and append them to a pin.StdVec_Force. The rnea method works well then with this vector. Thus, I close the issue.