Skip to the content
FixTheRobot Explore Robotics / Manipulator Basics / Labs / Lab 05

Manipulator Basics · Lab 05 of 10

Lab 05: Inverse Kinematics

Drag a target: analytical 2R IK with both elbows, pseudoinverse and damped least-squares IK, convergence and limits.

Objective

Find joint angles that put the tool on a target: analytically for the 2R arm (with both elbow solutions), and numerically with the Jacobian pseudoinverse and damped least squares for 3R and 6-DOF arms, watching convergence, joint limits and unreachable targets.

Brief theory

Inverse kinematics (IK) solves T(q)=TtargetT(q) = T_{\mathrm{target}} for qq. For the 2R arm the law of cosines gives a closed form:

Analytical 2R IK
c2=x2+y2−L12−L222L1L2,q2=atan2⁡ ⁣(±1−c22, c2),q1=atan2⁡(y,x)−atan2⁡(L2sin⁡q2, L1+L2cos⁡q2)c_2 = \frac{x^2+y^2-L_1^2-L_2^2}{2L_1L_2},\quad q_2 = \operatorname{atan2}\!\left(\pm\sqrt{1-c_2^2},\, c_2\right),\quad q_1 = \operatorname{atan2}(y,x) - \operatorname{atan2}(L_2\sin q_2,\, L_1 + L_2\cos q_2)
The ± gives the two branches (elbow up and elbow down). |c₂| > 1 means the target is out of reach.

Numerical IK iterates on the task error ee: Δq=J+e\Delta q = J^{+} e (pseudoinverse) or Δq=J⊤(JJ⊤+λ2I)−1e\Delta q = J^{\top}(JJ^{\top} + \lambda^2 I)^{-1} e (damped least squares, DLS). DLS trades a little accuracy for bounded steps near singularities. Each iteration here is a real step from the current configuration; nothing is precomputed. Module 07 has the derivations.

Simulation workspace

Drag the 3D view to orbit, scroll or pinch to zoom. Every number shown is computed live by the simulation engine running in your browser.

Loading the simulation…

Guided tasks

Each task ticks itself when the simulation sees you do it. Progress is saved in this browser.

  1. Move the targetDrag the target in the 2D view or use the target sliders.
  2. Solve IKSolve once analytically (2R) and once numerically.
  3. Select an IK solutionSwitch between elbow up and elbow down for the same target.
  4. Observe convergenceRun a numerical solve that converges and look at the error plot (log scale).
  5. Introduce an unreachable targetPut the target outside the reachable annulus and read what each method reports.
  6. Adjust the initial configurationChange the start configuration and solve again: a different start can give a different solution.

Challenges

Each challenge states an objective, its constraints and how success is measured. The live line under it is computed from the simulation. Hints and full solutions are there when you want them.

Success criteria

  • Every solution shown is verified by passing it back through forward kinematics: the residual is displayed and must be below 0.1 mm to count as solved.
  • For an unreachable target the analytical solver says why and the numerical solvers stop with the smallest residual they found, never claiming success.

Explanation of the results

The analytical solver is exact: its residual is at the level of floating-point rounding (about 10−1610^{-16} m). The numerical solvers stop when the residual is below the tolerance, so their solutions are accurate to that tolerance, not exact. Damped least squares takes smaller steps than the pseudoinverse near singular configurations (a stretched arm), which is why it converges more reliably from bad starts and why, for an unreachable target, it settles on the closest reachable point instead of oscillating.

Different starting configurations converge to different solutions because a 2R or 3R arm generally has several (and a 6-DOF arm up to sixteen). Real IK solvers therefore seed from the current configuration to stay on the same branch, and check joint limits and collisions before accepting a solution.