-
Notifications
You must be signed in to change notification settings - Fork 67
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
Adapt iDynTree to use automatic differentiation #673
Comments
I haven't worked on it for a while now. But it should still be working. Notice though that
I remember some discussion with @traversaro where the main idea was basically to make at least Another thing to take into considerations is the use of the vectors and matrices to be used. For AD to work, it may be necessary to redefine the primitive types. Hence, Having said this, I strongly believe this is an interesting direction 👍 |
Thanks for opening the issue! It is not so complex or long, it just needs some dedicated and focus work. I think there are basic two main possible non-conflicting paths (that have been already mentioned by @S-Dafarra, I just mention them separately for clarity): Modify iDynTree core data structures and algorithms to enable autodiffIn a nutshell, it boils down to modify all the data structures and functions from:
to
And then try to instantiate all the algoritms with an appropriate autodiff scalar, and deal with all the problem you will find. : ) Note that given that with C++17 and Eigen 3.4 all the issue related to However, if you are interested in minimizing computational speed, that may not be the best options as due to some internal choices, for sure iDynTree is not the fastest possible implementation of rigid body dynamics algorithms. For this reason, I think the next options is appealing. Create a KinDynComputations interface to support different KinDynComputations implementationsAs 95% of the users of iDynTree actually use the The main advantage of this approach is that we would automatically get a much faster Implementation detail on a pinocchio-based
|
// Process right side of the jacobian |
// Account for the different possible representations |
// Convert input base acceleration |
You can find more info about this in Computation of "Classic" Cartesian velocity of a frame stack-of-tasks/pinocchio#1140 . Note that it is important that also this conversion functions are templated, as if you want to compute the autodiff of the massmatrix in the iDynTree convention, you need to take in consideration also the effect of this transformations.
Once you have done so, testing is fortunatly easy as we already have an existing KinDynComputations that can serve as a reference, and so we can just test the methods of KinDynComputations for the two backends on an arbitrary model and arbitrary inputs, and verify that the one computed by a pinocchio-backend are faster.
I think that developing a pinocchio-based KinDynComputations backend is probably the best option at the moment, and I don't think it requires a crazy amount of time. If anyone wants to work on it, I would be happy to provide support and handle the CMake and CI part, if necessary. |
What do you think to schedule a meeting for discussing this? @traversaro @S-Dafarra |
When you want, those are the kind of topics over I can also have beer meetings. |
Looks very promising. If from the pinocchio's side, we can provide any help, it would be with great pleasure (and much more around a beer ;)) |
Today we had a brief discussion with @S-Dafarra @GiulioRomualdi and @diegoferigo . Main points:
Given that the discussion has been done, I think we can close this issue and open new issues on the specific issues as soon as they are clear (I already opened #674 for example ). |
While I guess that CasADi + Pinocchio may be a good way to go for us, for the logistics of dealing with Ipopt/CasADi on Windows/macOS/Linux and on C++/Python/Matlab, it may be worth to check https://github.com/opensim-org/opensim-moco . |
Regarding the discussion that we had yesterday @DanielePucci @Giulero |
iDynTree
is a wonderful library and it allows us to efficiently retrieve all the robot kinematics and dynamics quantities. However using, at the current stage is not possible to use automatic differentiation-algorithms for computing the derivatives of given quantities. Having such derivatives may allow the user to design complex control/estimation algorithms.In the past @S-Dafarra implemented a Semi-automatic differentiation library named levi, however I don't know the current status and if it is easy to use it inside iDynTree.
Another interesting framework is pinocchio where the support of modern Automatic Differentiation frameworks like
CppAD
orCasADi
is guaranteed.This issue is just for discussing proposals and ideas. I know that this a moonshot and adapting
iDynTree
for enabling the automatic differentiation is a really long and complex task, however I think this is the right moment for starting the discussion.The text was updated successfully, but these errors were encountered: