Skip to content

MechanicsFrames and Kinematics

Inverse Kinematics of a Two-Link Arm

Given where the hand should go, the law of cosines gives the elbow angle; there are usually two answers, and sometimes none.

Not started Jump to practice

Usually we want the opposite: put the hand there. Which joint angles do that? This is inverse kinematics.

Key idea

For a two-link arm and target $(x, y)$, let $r^2 = x^2 + y^2$. The law of cosines gives the elbow: $\cos\theta_2 = \dfrac{r^2 - L_1^2 - L_2^2}{2 L_1 L_2}$. If that is outside $[-1, 1]$, the target is out of reach. Otherwise there are usually two answers, elbow up and elbow down. Then $\theta_1 = \operatorname{atan2}(y, x) - \operatorname{atan2}(L_2\sin\theta_2,\ L_1 + L_2\cos\theta_2)$.
Drag the target. The arm finds its angles; switch between elbow up and elbow down. Drag it out of reach and see what happens.

Why it works

The two links and the line from the shoulder to the target make a triangle with sides $L_1$, $L_2$ and $r$. The law of cosines finds the angle between the links. A triangle can be flipped over its long side, which is why there are two answers.

Worked example: Find the elbow

$L_1 = 10$, $L_2 = 7$, target $(12, 5)$.
  1. $r^2 = 144 + 25 = 169$, so $r = 13$.
  2. $\cos\theta_2 = \dfrac{169 - 100 - 49}{140} = \dfrac{20}{140} \approx 0.143$.
  3. $\theta_2 \approx \pm 81.8^\circ$.

Answer: About 81.8Β° (elbow down) or βˆ’81.8Β° (elbow up).

Worked example: Out of reach

Same arm, target $(15, 9)$.
  1. $r = \sqrt{225 + 81} \approx 17.5$, more than $L_1 + L_2 = 17$.

Answer: No solution: the target is out of reach.

Common mistake

Forgetting to check that the target is in reach, or missing the second solution.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 3 XP.

Loading practice…

Builds on

Leads to

This is one of the top rungs of Mechanics and Motion.

Sources and further reading