Skip to content

Commit 90913be

Browse files
committed
Document damped least squares
1 parent f727692 commit 90913be

File tree

1 file changed

+5
-1
lines changed
  • src/pytorch_kinematics

1 file changed

+5
-1
lines changed

src/pytorch_kinematics/ik.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def __init__(self, serial_chain: SerialChain,
148148
:param pos_tolerance: position tolerance in meters
149149
:param rot_tolerance: rotation tolerance in radians
150150
:param retry_configs: (M, DOF) tensor of initial configs to try for each problem; leave as None to sample
151-
:param num_retries: number, M, of random initial configs to try for that problem
151+
:param num_retries: number, M, of random initial configs to try for that problem; implemented with batching
152152
:param joint_limits: (DOF, 2) tensor of joint limits (min, max) for each joint in radians
153153
:param config_sampling_method: either "uniform" or "gaussian" or a function that takes in the number of configs
154154
:param max_iterations: maximum number of iterations to run
@@ -295,8 +295,12 @@ def solve(self, target_poses: Transform3d) -> IKSolution:
295295
m = m.view(-1, self.num_retries, 4, 4)
296296
dx, pos_diff, rot_diff = delta_pose(m, target_pos, target_rot_rpy)
297297

298+
# damped least squares method
299+
# JJ^T + lambda^2*I (lambda^2 is regularization)
298300
tmpA = J @ J.transpose(1, 2) + self.regularlization * torch.eye(6, device=self.device, dtype=self.dtype)
301+
# (JJ^T + lambda^2I) A = dx
299302
A = torch.linalg.solve(tmpA, dx)
303+
# dq = J^T (JJ^T + lambda^2I)^-1 dx
300304
dq = J.transpose(1, 2) @ A
301305
dq = dq.squeeze(2)
302306

0 commit comments

Comments
 (0)