Skip to content

Commit

Permalink
fix jacobian
Browse files Browse the repository at this point in the history
  • Loading branch information
neka-nat committed Feb 5, 2021
1 parent d63effc commit 671731e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kinpy/jacobian.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def calc_jacobian(serial_chain, th, tool=transform.Transform()):
if f.joint.joint_type == "revolute":
cnt += 1
delta = np.dot(f.joint.axis, cur_transform[:3, :3])
d = np.cross(delta, cur_transform[:3, 3])
d = np.dot(np.cross(f.joint.axis, cur_transform[:3, 3]), cur_transform[:3, :3])
j_fl[:, -cnt] = np.hstack((d, delta))
elif f.joint.joint_type == "prismatic":
cnt += 1
Expand Down
11 changes: 10 additions & 1 deletion tests/test_jacobian.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,17 @@ def test_jacobian2(self):
[0.0, 0.0],
[0.0, 0.0],
[1.0, 0.0]]), jc)


def test_jacobian3(self):
chain = kp.build_serial_chain_from_urdf(open("examples/kuka_iiwa/model.urdf").read(), "lbr_iiwa_link_7")
th = [0.0, -np.pi / 4.0, 0.0, np.pi / 2.0, 0.0, np.pi / 4.0, 0.0]
jc = chain.jacobian(th)
np.testing.assert_almost_equal(np.array([[0, 1.41421356e-02, 0, 2.82842712e-01, 0, 0, 0],
[-6.60827561e-01, 0, -4.57275649e-01, 0, 5.72756493e-02, 0, 0],
[0, 6.60827561e-01, 0, -3.63842712e-01, 0, 8.10000000e-02, 0],
[0, 0, -7.07106781e-01, 0, -7.07106781e-01, 0, -1],
[0, 1, 0, -1, 0, 1, 0],
[1, 0, 7.07106781e-01, 0, -7.07106781e-01, 0, 0]]), jc)

if __name__ == "__main__":
unittest.main()

0 comments on commit 671731e

Please sign in to comment.