Inverse kinematics

How does the arm know where to put its joints?

You point at the cup. Two motors have to agree on two angles. Scroll to take the arm apart.

Scroll the tour
θ₁ ?θ₂ ?
Fig. 27 · Two-link arm on a bench01 · Parts
ORBEFAB · 2R BENCH · L27Shoulder motorturns θ₁Link 1L₁ = 0.30 mElbow motorturns θ₂Link 2L₂ = 0.25 mGripperthe tip (x, y)
Scroll. The arm comes apart.θ₁ 68.0° θ₂ -86.2° tip (0.350, 0.200)
01 · The parts

Two links, two motors

A shoulder motor turns link 1 (θ₁). An elbow motor turns link 2 (θ₂). Pick both angles and the gripper lands somewhere.

Show the math
L₁ = 0.30 m, L₂ = 0.25 mtip x = L₁ cos θ₁ + L₂ cos(θ₁ + θ₂)tip y = L₁ sin θ₁ + L₂ sin(θ₁ + θ₂)Forward kinematics, lesson 25. Lesson 27 worked example.
02 · Reach

The ring it can touch

Fully stretched, the tip sits 0.55 m out. Fully folded, 0.05 m. Everything in between is the workspace.

Show the math
outer = L₁ + L₂ = 0.55 minner = |L₁ − L₂| = 0.05 mLesson 27 worked example 3.
03 · The triangle

Its shadow is a triangle

Look down. Shoulder, elbow and target form a triangle with three known sides. The law of cosines reads the elbow angle off it.

Show the math
cos θ₂ = (x² + y² − L₁² − L₂²) / (2·L₁·L₂)cup (0.35, 0.20): (0.1625 − 0.1525) / 0.15 = 0.0667θ₁ = atan2(y, x) − atan2(L₂ sin θ₂, L₁ + L₂ cos θ₂)Lesson 27, worked example 1.
04 · Two answers

Elbow down, elbow up

acos returns ±θ₂, so the same fingertip has two arms. The ghost is the other one.

Show the math
elbow down: θ₂ = +86.18°, θ₁ = −8.48°elbow up: θ₂ = −86.18°, θ₁ = 67.97°Both reproduce (0.35, 0.20) through FK to 1e-9.Lesson 27 worked example 1. checks/m4_6.py.
05 · Too far

Spin, or stretch and stop

Put the cup at 0.60 m. Plain Newton whirls. Damped least squares stretches toward the cup and stops at the fingertip. Example 3 starts both from (0.3, 0.3) rad.

Show the math
Newton: Δθ = J⁻¹ (x_d − f(θ)). Near full stretch J loses rank, so J⁻¹ blows up.DLS: Δθ = Jᵀ (J Jᵀ + λ² I)⁻¹ e, λ = 0.05Check script, example 3, start guess (0.3, 0.3) rad.Newton winds to about (18.7, −37.4) rad. The tip ends near x = 0.542.DLS keeps about (0.075, −0.17) rad. The tip stops at x = 0.548 m.Lesson 27 worked example 3. checks/m4_6.py. The trails are a live run of the same iteration.
06 · Now you try

Move the cup

Drag on the bench. The arm solves, the shadow triangle flexes, and the numbers update.

Show the math
Same law-of-cosines solution as the triangle step, solved on every move.Lesson 27, worked example 1.
Now you try

Which elbow is down?

ORBEFAB · 2R BENCH · L27L₁ 0.30L₂ 0.25d 0.403θ₂θ₁

Drag the cup, then name θ₂ for elbow down at (0.35, 0.20).

θ₁ -8.5° θ₂ 86.2° tip (0.350, 0.200) · tip error 0.0 mm

Now you try

Past the ring

ORBEFAB · 2R BENCH · L27L₁ + L₂ = 0.55 m0.05 m

Drag the cup out to (0.60, 0). Does the law of cosines name an angle?

θ₁ 0.0° θ₂ 0.0° tip (0.550, 0.000) · tip error 50.0 mm

Sandbox

Grab it. All three solvers.

Inverse kinematics: analytic and numeric

Check questions

  1. For L₁ = L₂ = 0.2 m, find θ₂ for target (0.2, 0.2). Answer: cos θ₂ = (0.08 − 0.08)/0.08 = 0 ⇒ θ₂ = ±90°. With θ₂ = −90°, θ₁ = 45° − atan2(−0.2, 0.2) = 90° (matches L25 Q1).
  2. Is (0.6, 0.1) reachable for L₁ = 0.3, L₂ = 0.25? Answer: distance = 0.608 m > 0.55 m ⇒ no (|cos θ₂| > 1).
  3. Why does the Newton step blow up near θ₂ = 0? Answer: J becomes singular (det J = L₁L₂ sin θ₂ → 0), so J⁻¹ has huge entries.
  4. With λ = 0, what does DLS reduce to (square, invertible J)? Answer: Jᵀ(JJᵀ)⁻¹ = J⁻¹: plain Newton–Raphson.

Sources

  • Modern Robotics (Lynch & Park, Dec 2019 preprint), Ch. 6 "Inverse Kinematics": §6.1 "Analytic Inverse Kinematics" (p. 219; decoupled position/orientation, θ₁ = atan2(p_y, p_x)), §6.2 numerical IK (p. 224) and §6.2.1 Newton–Raphson (p. 225; eq. 6.3–6.5, Fig. 6.7 convergence warning), §6.2.2 "Numerical Inverse Kinematics Algorithm" (p. 225) and the pseudoinverse (p. 227). https://hades.mech.northwestern.edu/images/2/25/MR-v2.pdf (local: ../sources/shared/modern-robotics-lynch-park-2019-preprint.pdf)
  • Robotic Manipulation (Tedrake), Ch. 3 "The Jacobian pseudo-inverse" and "Invertibility of the Jacobian" (pseudo-inverse blow-up as the smallest singular value → 0). https://manipulation.mit.edu/pick.html (local: ../sources/shared/manipulation-ch03-basic-pick-and-place.html)
  • mink documentation (differential IK library on MuJoCo; home page snapshot only). https://kevinzakka.github.io/mink/ (local: ../sources/L27/page-mink-docs.html)
  • Derived and checked: 2R law-of-cosines IK, the DLS identity and its behavior on the unreachable target.