mahaarbo / urdf2casadi

Python library for getting a casadi function for the forward kinematics of a URDF chain
MIT License
95 stars 32 forks source link

calculate the jacobian matrix using derivative method #30

Closed wly2014 closed 8 months ago

wly2014 commented 10 months ago

calculate the jacobian matrix using derivative method.

mahaarbo commented 8 months ago

Thank you for the contribution, however I don't think this contribution is actually a geometric Jacobian since it assumes a local representation (Roll pitch yaw) which will negate the geometric structure of rigid body motion. The geometric Jacobian (also called manipulator Jacobian, see "A Mathematical Introduction to Robotic Manipulation" by Murray&Li, p.115, chapter 4), is supposed to be the mapping from R^n to SE(3). We ignore that in this library and just use the elementwise derivative of the transformation matrix T_fk with respect to the joints q. This is, of course, wrong since it should be a perfectly skew-symmetric object. Locally this is fine, but in reality, we are not adhering to the geometry of rotations. For users this means that it is their job to ensure that the rotations are reprojected to det(R)=1. The geometric jacobian that you are outputting is calculating the Euler angles from the transformation matrix for a specific choice of Euler angles and taking the derivatives of it with respect to the joints q. This is also wrong since the calculation of the Euler angles always has multiple solutions (e.g. sin(theta) = sin(pi-theta), likely requiring conditionals for sanity checks), and will still be only locally correct. It would be good to have a function that calculates the manipulator Jacobian using the method of Murray&Li as it is useful in f.ex. compliance control, but I fear adding a Jacobian function that outputs the derivative of a specific Euler angles convention will only confuse users.