Inverse Kinematics and Workspace
Learning Objectives
- State the inverse kinematics problem and its three possible outcomes: no solution, finitely many, infinitely many.
- Solve a planar two-link arm in closed form with
atan2, produce both elbow solutions, and state the reach condition. - Run Newton's method on the same arm, recognize quadratic convergence, and predict how it fails when the start or the solution is at a singular configuration.
- Distinguish the reachable workspace from the dexterous workspace, derive both for a planar three-link arm, and estimate them by sampling with a named generator, seed and size.
Context & Motivation
the-denavit-hartenberg-convention turned an arm into a table, and the table into a function: joint angles in, pose out. A task arrives the other way round. A camera reports where a part lies, and the controller needs joint angles that put the gripper there. That is inverse kinematics: given a desired end-effector position or pose , find with .
Forward kinematics always has exactly one answer. The inverse can have none (the target is out of reach), several (the elbow can bend either way), or infinitely many (the arm has more joints than the task needs). Some arms admit a formula. For the rest there is iteration, and the iteration is Newton's method from newtons-method, now in several variables, with all of its failure modes in robot form.
Core Theory
The planar two-link arm
Take link lengths and , joint angles measured counterclockwise, from the axis and relative to link 1. The tip is
with . Squaring and adding removes , since . So
A solution exists exactly when , that is . Strictly inside that annulus there are two solutions, one for each sign of . On either boundary circle there is one, with the arm stretched () or folded (). The exception is , where the inner circle shrinks to the base and the folded arm reaches it at every . atan2 matters here: it returns the angle in the correct quadrant on , which cannot do.
Names for the two branches vary. Modern Robotics calls them "lefty" and "righty" or "elbow-up" and "elbow-down", and which is which depends on how the arm is viewed. The sign of is unambiguous, so this lesson uses it.
Larger arms
The same pattern, decouple and use plane geometry, gives closed forms for many industrial layouts. For a planar three-link arm with a desired orientation , subtract the last link to get the wrist point and solve the two-link problem for . Six-joint arms whose last three axes meet at a point split the same way into a position problem and an orientation problem. For geometries without such a split, a numerical method is the usual tool.
Newton's method for inverse kinematics
Let and let , the matrix of partial derivatives (built in general in velocity-kinematics-and-the-jacobian). For the two-link arm,
Linearizing at and solving for a zero error gives
This is the scalar iteration of newtons-method with the division replaced by a linear solve, as that lesson anticipates. The scalar theory carries over: near a solution where is invertible, the error is roughly squared at each step. Two hypotheses can fail in a robot-specific way. The determinant vanishes when , so a start with the arm stretched or folded makes the step undefined. And if the solution itself has , which happens for every target on the boundary of reach, the root is degenerate, like the double root of newtons-method.
Modern Robotics replaces by the pseudoinverse when is not square or not invertible, and notes that the iteration tends to converge to the solution closest to the initial guess, each solution having its own basin of attraction.
Reachable and dexterous workspace
Murray, Li and Sastry define the reachable workspace as the set of positions the end effector reaches "at some orientation", and the dextrous workspace (their spelling) as the set of positions reached "with arbitrary orientation". The second is contained in the first. For a planar arm, "arbitrary orientation" means every heading in the plane.
For a planar three-link arm with and , their Example 3.4 finds that the reachable workspace is the annulus , and that the dexterous workspace is smaller by at each edge. The reason comes straight from the wrist-point reduction: a position works for heading exactly when lies in the two-link annulus . Reachable means one heading works. Dexterous means the whole circle of radius around fits inside that annulus, which gives .
Worked Examples
All lengths below are assumed for illustration: m, m, and in Example 4 a third link m. Angles are in degrees unless marked.
Example 1: both elbow solutions in closed form
Target m, at distance m, inside the annulus . Then , and
textbranch theta1 theta2 elbow position tip error theta2>0 -3.7231 74.0380 (0.998, -0.065) 0 theta2<0 48.9628 -74.0380 (0.657, 0.754) 2.2e-16
Both satisfy the forward kinematics to rounding. They are mirror images across the line from base to target: one elbow sits below that line, the other above it. Which one a robot should use is a task decision (obstacles, joint limits, the current posture), not a kinematic one.
Example 2: Newton's method, and which solution it finds
From the error norms in metres are
and the run lands on the solution. The first step barely helps, then the exponent roughly doubles, the pattern of quadratic convergence. From it takes four steps, , , , , , to the solution. The start chose the branch.
Example 3: Newton's method near singular configurations
Start on a singularity. Starting from the zero posture , the stretched arm, gives , and numpy.linalg.solve raises LinAlgError: Singular matrix on the first step. The zero posture is a natural default guess, which makes this failure common.
Start next to one. From the condition number of is and the first step is radians. The run then converges in five more steps to joint angles of about and degrees, which modulo are exactly the solution. But the residual stalls at m instead of : near rad, consecutive doubles are rad apart, so the angle itself cannot be stored more precisely. A real controller would also reject a command of thousands of turns.
Solution on a singularity. The target is on the outer boundary, with unique solution , where . From :
textk theta1 theta2 |e| (m) cond(J) theta2_k/theta2_(k-1) 0 10.00000 30.0000000 6.0e-02 9.1e+00 1 14.29521 14.9948396 1.3e-02 1.9e+01 0.4998 2 17.18841 7.4858672 3.2e-03 3.7e+01 0.4992 5 19.64928 0.9352169 5.0e-05 3.0e+02 0.5000 10 19.98904 0.0292253 4.9e-08 9.5e+03 0.5000 23 20.00000 0.0000030 7.4e-16 9.2e+07 0.4399
The joint error halves at every step: linear convergence with ratio , the same ratio newtons-method found for a double root in one variable. The task error falls by four per step because, at the stretched arm, distance from the boundary grows with the square of . That also makes the residual misleading: at the tip is within m of the target, while is still rad from its true value.
Target out of reach. For no solution exists, and the best possible error is m. Over 30 iterations from , jumped between and m, and reached degrees at . Nothing in the iteration announces that the target is infeasible. Checking the reach condition first, when one is available, is cheaper.
One common remedy for the first two failures replaces the step by the damped least-squares step , which stays finite when is singular. With m it reached the solution from exactly in 11 iterations, to m. singularities-and-manipulability returns to this trade-off.
Example 4: reachable and dexterous workspace by sampling
Add m. The assumptions of Murray, Li and Sastry hold ( and ), so the exact answers are the annuli (reachable, area m²) and (dexterous, area m²).
Sampling the joints. With rng = numpy.random.default_rng(2026) and Q = rng.uniform(-pi, pi, (100_000, 3)), the tip radii ranged from to m, so the extremes are found. The density is another matter. Comparing each radial band's share of samples with its share of area:
textband (m) 0.1-0.4 0.4-0.7 0.7-1.3 1.3-1.6 1.6-1.9 samples/area 1.61 1.57 1.21 0.91 0.57
Uniform joint angles do not give uniform positions. The outer band, where the arm must be nearly straight, gets 57 percent of its fair share, so joint sampling is a poor way to estimate areas.
Sampling the plane. With a fresh numpy.random.default_rng(2026), draw 200,000 points uniformly in the square (area 16 m²). For each point test 360 evenly spaced headings: the heading works if the wrist point falls in the two-link annulus . A point is reachable if some heading works and dexterous if all 360 do.
textpoints area estimate (m^2) exact std. error sampled radii (m) reachable 141,102 11.288 11.310 0.016 0.10002 to 1.89996 dexterous 47,053 3.764 3.770 0.015 0.70000 to 1.29999
Both estimates are within 1.5 standard errors of the exact areas. The 360-heading grid can only overestimate the dexterous set, since a point could fail at a heading between grid lines, but here the sampled radii stay inside . Along the axis, the share of headings that work is at , at , at , at and at . A gripper that must approach from any side has only the middle band, a third of the reachable area.
Common Misconceptions & Pitfalls
- "Inverse kinematics has one answer." Example 1 has two, and both are exact. Joint limits and obstacles choose between them.
- "Newton's method finds the nearest solution." It often does, but Example 3 started rad from one posture and ended millions of degrees away.
- "The zero posture is a safe initial guess." For this arm it is singular, and the solver stops on the first step.
- "A tiny residual means the joints are right." At the boundary the residual was m with a joint error of rad, and convergence was linear, not quadratic.
- "Non-convergence means a bad start." It can mean an unreachable target. Check reach before iterating.
- "The reachable workspace is where the robot can work." For a task that needs every approach direction, only the dexterous workspace counts, here a third of the reachable area.
- "Sampling joints uniformly samples the workspace uniformly." The outer band received 0.57 of its share.
Summary
Inverse kinematics asks for joint values that produce a given pose, and may have no, several or infinitely many answers. For a two-link arm the law of cosines and atan2 give both elbow solutions whenever , and wrist-point decoupling extends this to many larger arms. Newton's method solves at each step, converges quadratically from a good start, and picks the solution by its basin. It breaks at singular configurations: a stretched start gives a singular matrix, a nearly stretched one a step of rad, a target on the boundary linear convergence with ratio , and an unreachable target no convergence at all. The reachable workspace counts positions reached at some orientation, the dexterous workspace those reached at every orientation. For lengths , , m they are the annuli and , which plane sampling with a fixed seed reproduced to within 0.2 percent of area.