JOVANA
Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Reaching a Target: Inverse Kinematics, Analytic and Numerical

Run the geometry backward: given where you want the hand, solve for the joint angles that put it there.

The Question Robots Actually Face

The previous guide ran the chain forward: given a set of joint angles, forward kinematics tells you exactly where the hand ends up. That is a satisfying answer, but it is not the question a robot is usually asked. Nobody tells a robot "set joint two to 37 degrees." They say "grab that cup." The robot knows the pose — the position and orientation — it wants for its end-effector, and it must work out what joint angles will put it there. That backward problem is inverse kinematics, or IK for short.

Think of the difference like arithmetic versus algebra. Forward kinematics is plugging numbers into a formula and computing the result — always one clean answer. Inverse kinematics is being handed the result and asked to find the inputs, which is the harder direction. The map from joint angles to hand pose lives in two different spaces: the angles live in joint space (one number per joint), and the hand pose lives in task space (where the gripper is in the room). IK is the bridge that takes you from task space back to joint space.

Why the Reverse Map Is Hard

Forward kinematics has the comforting property that every input gives exactly one output. Inverse kinematics breaks that promise in two directions at once. First, a target may have many valid solutions. Hold your own arm out and touch a point in front of you: you can reach it with your elbow swung high or swung low. A robot arm has the same freedom — engineers call these the "elbow-up" and "elbow-down" configurations, and both put the hand in exactly the same place. A typical six-joint arm can have up to eight distinct solutions for one target pose.

Second, a target may have no solution at all. If you ask the arm to reach a point beyond its reachable workspace — the set of all poses the hand can physically attain — there is simply no set of joint angles that gets there. Ask for a cup on a shelf one centimeter past full stretch and the honest answer is "I can't." Good IK code must detect this case and report failure rather than return garbage angles that fling the arm somewhere wrong.

And there is a third wrinkle. An arm with more joints than the task strictly needs — a redundant arm, like a seven-joint arm doing a six-dimensional task — has not just a handful of solutions but an infinite, continuous family of them. You can wave the elbow around in an arc while the hand stays perfectly still. That is a gift for avoiding obstacles, but it means "the" answer doesn't exist; you have to pick one.

Analytic IK: Solving the Triangles by Hand

For arms with a tidy geometry, you can solve IK the way you'd solve a geometry homework problem: with trigonometry, by hand, once, ahead of time. This is analytic inverse kinematics — also called closed-form IK because the answer is an exact formula, not an approximation. You feed in the target pose and out come the joint angles directly, like plugging into the quadratic formula.

The classic enabler is a spherical wrist — the last three revolute joints all crossing at a single point. That arrangement lets you cleanly split the problem in two: the wrist point's position is decided by the first three joints, and the hand's orientation is decided by the last three. Two small trigonometry problems instead of one tangled six-dimensional one. Most industrial arms are deliberately built with a spherical wrist for exactly this reason — it makes them solvable in closed form.

Two-link arm in a plane, hand target = (x, y), link lengths L1, L2:

  r2 = x*x + y*y                      # squared distance to target
  cos_e = (r2 - L1*L1 - L2*L2) / (2*L1*L2)

  if cos_e < -1 or cos_e > 1:
      FAIL  -> target is outside the reachable workspace

  elbow = acos(cos_e)                 # the +/- below give the two solutions
  shoulder = atan2(y, x) - atan2(L2*sin(elbow), L1 + L2*cos(elbow))

  # solution A: (shoulder, +elbow); solution B: mirror with -elbow
  # the two signs are the elbow-up and elbow-down configurations
A toy two-joint arm in closed form: notice the out-of-range check that catches unreachable targets, and the plus/minus on the elbow that yields the two elbow-up / elbow-down configurations.

The payoff is enormous. A closed-form solution runs in microseconds, finds every solution at once, and never gets stuck or wanders. The catch is that it only exists for arms with the right special structure, and deriving it is painstaking, geometry-specific work — change the arm's dimensions in a way that breaks that structure, or add a joint, and you may have to derive the whole thing again from scratch.

Numerical IK: Guess, Check, Nudge, Repeat

When no clean formula exists — an odd geometry, a custom arm, or one with extra joints — you fall back on numerical inverse kinematics. Instead of solving the equations exactly, you sneak up on the answer: start from a guess and improve it step by step until the hand is close enough to the target. It's the same instinct as adjusting your reach when you're a little off: you see the gap and lean a bit further.

The engine that makes the nudging precise is the Jacobian. The Jacobian is a matrix that says, for the arm's current pose, how a small twist of each joint moves the hand. Read it forward and it predicts hand motion from joint motion; invert it and it tells you which joint motions produce the hand motion you want — namely, the small motion that closes the gap to the target.

  1. Start with a guess for the joint angles (often the arm's current pose).
  2. Run forward kinematics on the guess and measure the error: how far, in position and orientation, is the hand from the target?
  3. Use the inverted Jacobian to turn that hand-error into a small correction for each joint angle.
  4. Apply the correction, then loop back to step 2. Each pass shrinks the error.
  5. Stop when the error is below your tolerance — or give up after a fixed number of tries if it isn't shrinking.

This loop is wonderfully general — give it any arm and a forward-kinematics function and it will try, no hand derivation required. But that generality comes with strings. It returns only one solution (whichever one it happened to converge toward from your starting guess), it can be slow if it needs many iterations, and it can stall near a singularity, a pose where the arm momentarily loses the ability to move in some direction and the Jacobian becomes impossible to invert cleanly. Near those poses the requested joint corrections blow up, and a naive solver flails.

Picking the Right Tool

The two methods aren't rivals so much as tools for different jobs. Analytic IK wins on speed, completeness, and reliability: microseconds per call, every solution at once, no risk of getting stuck. It's the right choice for a standard six-axis arm on a production line running the same closed-form solver a million times a day.

Numerical IK wins on flexibility. It handles arms that have no closed-form solution, redundant arms where you want to pick a clever configuration that also dodges an obstacle, and research robots whose geometry changes between experiments. You pay for that with speed and the need to watch out for singularities and bad starting guesses — but the same machinery extends naturally to also satisfying secondary goals, like keeping the elbow tucked while the hand stays on target.

In practice the line blurs. Many systems run analytic IK when the arm's structure allows it and fall back to a numerical solver otherwise. And when a redundant arm has infinitely many answers, the numerical method's freedom to roam becomes the headline feature — that spare motion is exactly the null-space motion you'll meet in the redundancy guide, where the hand holds still while the elbow rearranges to do something useful.