Inverse Kinematics for custom robot. Help required to build proper reduced model to generate IK solver. #2076
-
Dear @jorisv, Previously you helped me out in this discussion thread.
The Forward Kinematics is working fine. My end effector link name is (quaternion in w,x,y,z format) I should get a joint values of
For inverse kinematics I think I am probably not passing the correct joint ID. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @threedee003, Your IK code is minimizing the error between the The following code will do the job (I put comment to explain the difference with your code) : while True:
# framesForwardKinematics instead of forwardKinematics to compute the frame configuration
pin.framesForwardKinematics(self.reduced_model, self.model_data, q)
# oMf instead of oMi to take the frame (not the joint)
iMd = self.model_data.oMf[self.id_end_effector].actInv(oMdes)
err = pin.log(iMd).vector
if np.linalg.norm(err) < eps:
success = True
break
if iter >= epochs:
success = False
break
# computeFrameJacobian instead of computeJointJacobian to compute the frame jacobian
J = pin.computeFrameJacobian(
self.reduced_model,
self.model_data,
q,
self.id_end_effector,
)
J = -np.dot(pin.Jlog6(iMd.inverse()), J)
v = -J.T.dot(np.linalg.solve(J.dot(J.T) + damp * np.eye(6), err))
q = pin.integrate(self.reduced_model, q, v * dt)
iter += 1 Also, instead of defining you own quaternion to matrix function The result configuration can still be different from the one you want. Because of singularities, the optimization process can make big step. You can play with the initial configuration, |
Beta Was this translation helpful? Give feedback.
Hello @threedee003,
Your IK code is minimizing the error between the
joint
6 (that support ur_arm_flange) and the desired configuration.You should minimize the error between the
frame
ur_arm_flange and the desired configuration.The following code will do the job (I put comment to explain the difference with your code) :