robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
172 stars 67 forks source link

KinDynComputations::inverseDynamics segfaults on inputs with wrong shape #1118

Open traversaro opened 1 year ago

traversaro commented 1 year ago

@fils99 was affected by this.

traversaro commented 1 year ago

He was using code like:


baseForceAndJointTorques = iDynTree.FreeFloatingGeneralizedTorques()
    # baseForceAndJointTorques = iDynTree.MatrixDynSize(6+dofs, 1);
    ok = dynComp.inverseDynamics(baseAcc, accelerations_joints[:, time_instant], linkExtForces, baseForceAndJointTorques);
fils99 commented 1 year ago

My error was due to the fact I was using iDynTree.FreeFloatingGeneralizedTorques() and iDynTree.LinkWrenches() without giving them the model I was using. The correct use of these classes is:

baseForceAndJointTorques = iDynTree.FreeFloatingGeneralizedTorques(dynComp.model())
linkExtForces = iDynTree.LinkWrenches(dynComp.model())

Thanks for the help, @traversaro !