pinocchio icon indicating copy to clipboard operation
pinocchio copied to clipboard

Usage of Casadi SX with Pinocchio

Open UM-A opened this issue 1 year ago • 1 comments

Hi, I think this question has been asked previously and there were some answers. I want to go from my urdf file to Casadi SX robot equations. As far as I understand, it might be possible to do with pinocchio. However, when I try to use those expressions I get errors. I am sharing the code snippet, in case I am doing something wrong. Looking forward to any responses.

Code: model=pinocchio.buildModelFromUrdf("RobotURDF.urdf" ) data=model.createData() q = SX.sym("q", model.nq)

M = pinocchio.computePotentialEnergy(model, data, np.array([q[0],q[1],q[2],q[3]]))

Error: Python argument types in pinocchio.pinocchio_pywrap.computePotentialEnergy(Model, Data, numpy.ndarray) did not match C++ signature: computePotentialEnergy(struct pinocchio::ModelTpl<double,0,struct pinocchio::JointCollectionDefaultTpl> model, struct pinocchio::DataTpl<double,0,struct pinocchio::JointCollectionDefaultTpl> {lvalue} data) computePotentialEnergy(struct pinocchio::ModelTpl<double,0,struct pinocchio::JointCollectionDefaultTpl> model, struct pinocchio::DataTpl<double,0,struct pinocchio::JointCollectionDefaultTpl> {lvalue} data, class Eigen::MatrixBase<class Eigen::Matrix<double,-1,1,0,-1,1> > q)

UM-A avatar Nov 07 '23 12:11 UM-A

Hello @UM-A,

Pinocchio 2 is only supporting Casadi in C++. The Python support will be added in Pinocchio 3 that is not released and not public.

Hopefully a pre-release is available. You can find instruction in this tutorial. I recommend you to install it with conda (in a new environment), then to run the setup notebook to test your installation.

Others notebook will show you how to use the Pinocchio Casadi binding (from pinocchio import casadi as cpin).

jorisv avatar Nov 08 '23 15:11 jorisv