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

Issue with importing pinocchio.casadi #2317

Closed waynekyrie closed 1 month ago

waynekyrie commented 1 month ago

Bug description

I installed Pinocchio following the instructions here https://stack-of-tasks.github.io/pinocchio/download.html using robotpkg on a Ubuntu 20.04 machine with python 3.8. But when I do import pinocchio.casadi, it gives the error msg saying no module named pinocchio.casadi.

Is there anything else that needs to be done? Thank you.

fabinsch commented 1 month ago

Hi @waynekyrie, to simplify, you can create a new conda environment and install Pinocchio using:

conda create --name myenv
conda activate myenv
conda install pinocchio -c conda-forge

Afterward, you can import pinocchio.casadi. Alternatively, building Pinocchio from source is also an option.

nim65s commented 1 month ago

casadi support is not yet enabled on robotpkg. It will be in the following weeks.

waynekyrie commented 1 month ago

Thanks for the prompt reply! Is it the same case that casadi is not supported when using homebrew to install on Mac OS X?

fabinsch commented 1 month ago

casadi is not supported when using homebrew to install on Mac OS X

correct.

waynekyrie commented 1 month ago

Thanks so much. It is resolved by using conda.

A follow-up question. After I import pinocchio.casadi, I want to use the rnea() function to calculate the inverse dynamics. However, my pos, vel, and acc are in the type of Casadi.MX, whereas rnea() takes Casadi.SX (if I understand correctly). In this case, is it still possible to use rnea(), or are there other ways to do inverse dynamics from MX?

jcarpent commented 1 month ago

You should use SX and not MX with Pinocchio, as it is much more efficient.