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.78k stars 375 forks source link

Compute second-order derivative of generalized static torque #2092

Closed IoannisDadiotis closed 6 months ago

IoannisDadiotis commented 9 months ago

Hi,

I would like to ask how can I analytically compute the second-order derivative of the generalized static torque wrt the configuration vector q.

\tau = g(q) - \sum J(q)^T f_{ext}

I can see in the documentation there is computeStaticTorque() and computeStaticTorqueDerivatives() but not a direct method for the second-order derivative.

I am encountering the following options:

Thank you in advance for any information!

P.S. While writing this issue I realized that ComputeRNEASecondOrderDerivatives is written with capital C in contrast to other compute*methods in pinocchio. So maybe this is something you want to fix in the future.

jcarpent commented 9 months ago

P.S. While writing this issue I realized that ComputeRNEASecondOrderDerivatives is written with capital C in contrast to other compute*methods in pinocchio. So maybe this is something you want to fix in the future.

Yes, you're totally right. I will fix this issue.

cmastalli commented 9 months ago

Hi @IoannisDadiotis,

Pinocchio's support for second-order derivatives is not fully available. This goes beyond implementing classical algorithms, and it requires further research. This responds to your first question.

When computing the first or second-order derivatives for static torques only, then we can leverage this fact and reduce computation. This could be written in Pinocchio's documentation, I agree with this. I hope this responds to your second question. But if you are keen to know more about it, then it is most probably useful if you read Justin's and other papers on this topic.

Cheers, Carlos

IoannisDadiotis commented 9 months ago

Hi @cmastalli and thank you for the fast response! From your answer I understand that currently in pinocchio it's not possible to compute the second-order derivative of the generalized static torque wrt the configuration q under the presence of external forces (since the is no support for external forces in ComputeRNEASecondOrderDerivatives).

From my side the issue can be closed if you or @jcarpent have nothing to add.

jcarpent commented 9 months ago

We can do it. It will take time and certain engineering efforts. @IoannisDadiotis How do you want to collaborate on it?

jcarpent commented 9 months ago

@IoannisDadiotis kind reminder ;)

IoannisDadiotis commented 9 months ago

@jcarpent thanks for the reminder.

I don't think I have the time needed for this, considering that I am just a user of the library and I don't have previous experience on low-level developments within pinocchio. I have thought that for my application maybe it is easier and faster to access the 2nd order derivatives using automatic differentiation with CppADCodeGen.