Skip to content

Commit a457cda

Browse files
authored
Merge pull request #45 from fangnan99/fix/prismatic
fix mistake in prismatic joint calculation
2 parents fcadfde + 2bbb216 commit a457cda

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/pytorch_kinematics/frame.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ def get_transform(self, theta):
133133
rot = axis_and_angle_to_matrix_33(self.joint.axis, theta)
134134
t = tf.Transform3d(rot=rot, dtype=dtype, device=d)
135135
elif self.joint.joint_type == 'prismatic':
136-
t = tf.Transform3d(pos=theta * self.joint.axis, dtype=dtype, device=d)
136+
pos = theta.unsqueeze(1) * self.joint.axis
137+
t = tf.Transform3d(pos=pos, dtype=dtype, device=d)
137138
elif self.joint.joint_type == 'fixed':
138139
t = tf.Transform3d(default_batch_size=theta.shape[0], dtype=dtype, device=d)
139140
else:

src/pytorch_kinematics/jacobian.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def calc_jacobian(serial_chain, th, tool=None, ret_eef_pose=False):
4646
j_eef[:, :, -cnt] = torch.cat((position_jacobian, axis_in_eef), dim=-1)
4747
elif f.joint.joint_type == "prismatic":
4848
cnt += 1
49-
j_eef[:, :3, -cnt] = f.joint.axis.repeat(N, 1) @ cur_transform[:, :3, :3]
49+
j_eef[:, :3, -cnt] = (f.joint.axis.repeat(N, 1, 1) @ cur_transform[:, :3, :3])[:, 0, :]
5050
cur_frame_transform = f.get_transform(th[:, -cnt]).get_matrix()
5151
cur_transform = cur_frame_transform @ cur_transform
5252

0 commit comments

Comments
 (0)