robotology / urdf2casadi-matlab

MIT License
29 stars 9 forks source link

issue with fixed joints in the computeKinematics() function #14

Open VModugno opened 3 years ago

VModugno commented 3 years ago

Hi guys, I'm currently working with urdf2casadi-matlab and I have encountered an issue with the computeKinematics() function when I set some joints in the urdf as fixed. In particular, I get the error on line 34 ( X{i}{1,j} = eye(smds.NB) ) and I managed to fix it by changing this line with X{i}{1,j} = eye(6). In this way the code run but I'm not sure about the correctness of the change. I believe it is just an error about the dimension of the matrix X{i}{1,j} which should not depend on the number of active joints but should be always a 6x6 identity matrix. I would have wanted to compare the resulting kinematic with idyntree but I'm having some trouble defining which are the active joints in the object kinDynComp (which is the variable containing the idyntree object inside the computeMassMatrixIDynTree() function inside urdf2casadi-matlab). If you want I can run some test I just need to know how to set the active joints in the idyntree object. thank you for your help

singhbal-baljinder commented 3 years ago

Thanks for pointing out this issue @VModugno. Indeed the line you mentioned has a bug: https://github.com/robotology/urdf2casadi-matlab/blob/c91d729fd02309d5b600164665da604f78d1f23d/Utils/computeKinematics.m#L34 As you correctly noticed, it should be X{i}{1,j} = eye(6);. As for the fixed joints I have started implementing it in: https://github.com/robotology/urdf2casadi-matlab/blob/c91d729fd02309d5b600164665da604f78d1f23d/Utils/modelExtractionFunctions/accountForFixedJoint.m#L1-L65 I have only tested it with this URDF https://github.com/robotology/urdf2casadi-matlab/blob/master/URDFs/iCub_r_leg.urdf and it seemed to work. As for how to check the number of non fixed joints in iDynTree it should be sufficient to use the following command: kinDynComp.model().getNrOfJoints(). Alternatively, if for example you have a model with only single degree of freedom joints, you can use: kinDynComp.model().getNrOfDOFs().