Tutorial · Advanced · 22 min read
Inverse Kinematics of a Two-Link Robot Arm
Understand inverse kinematics for a planar two-link arm: elbow-up and elbow-down solutions, the reachable workspace, singularities, and unreachable targets.
Published
Forward kinematics is easy: given the joint angles, multiply the link transforms and you know where the tool is. Inverse kinematics runs the other way—given a target position, find joint angles that reach it—and that direction is where the interesting problems live. A planar two-link arm is the smallest example that shows all of them. Explore it in the Robot Arm Simulator.
The reachable workspace
With link lengths L₁ and L₂, the tool can only reach points inside an annulus (a ring). The outer radius is L₁ + L₂ (arm fully stretched) and the inner radius is |L₁ − L₂| (arm fully folded). Anything outside the ring is too far; anything inside the hole is too close. No joint angles can reach those points, so the correct answer is simply “unreachable.”
Two solutions: elbow-up and elbow-down
For most targets inside the ring, the elbow can bend two ways and still place the tool on the same point. These are the elbow-up and elbow-down configurations. They come from a ± in the law-of-cosines angle for the second joint:
cos(θ₂) = (x² + y² − L₁² − L₂²) / (2·L₁·L₂)
θ₂ = ± acos(cos(θ₂)) # + is one elbow, − is the other
θ₁ = atan2(y, x) − atan2(L₂·sin θ₂, L₁ + L₂·cos θ₂)
Because there are two valid answers, inverse kinematics is not a single function—it is a choice. Robots pick the configuration that keeps joints away from their limits, minimizes movement from the current pose, or avoids an obstacle.
Singularities
At the edges of the workspace—arm fully stretched or fully folded—the two solutions merge into one. These are singularities, and near them a small motion of the tool can demand a huge motion of the joints. Planners slow down or route around singular poses because the arm briefly loses the ability to move the tool in one direction.
When is there no solution?
A target has no solution when it falls outside the reachable ring, when it would require a joint angle the hardware forbids, or when it demands an orientation the available joints cannot produce. A good simulator distinguishes these cases honestly instead of snapping to the nearest pose and pretending it succeeded.
Analytic versus numerical solvers
For two or three links the geometry has a closed-form (analytic) solution, so you compute the joint angles directly, exactly, and fast. That makes analytic IK ideal for teaching and for testing. Redundant or fully spatial arms usually have no closed form and need numerical solvers that iterate toward a solution—more general, but slower and harder to reason about because they can miss solutions or stall near singularities.
Try it yourself
In the Robot Arm Simulator, drag the target around and watch the arm solve for it in real time. Toggle the elbow branch to see the alternate solution, push the target outside the ring to see an honest “unreachable,” and move toward the workspace edge to feel a singularity.
Further reading