Back to all posts
Tutorial

Part 3: Solving the "Where Am I?" Problem (IK)

Ensemble AI
June 20, 2026
7 min read

Welcome to Part 3 of "Robotics Zero to Hero." Forward Kinematics (Part 2) maps joint values to a tip pose. But in the real world a robot is handed a goal: "Grab the cup at (x,y,z)(x,y,z)." It must compute the joint values that achieve that pose. This is Inverse Kinematics (IK) — and it is where low-dimensional and high-dimensional robotics part ways most dramatically.

The Math: Inverting a Nonlinear Map

We want q\mathbf q such that FK(q)=xtargetFK(\mathbf q) = \mathbf x_{target}, i.e. we seek a root of

e(q)=xtargetFK(q)=0\mathbf e(\mathbf q) = \mathbf x_{target} - FK(\mathbf q) = \mathbf 0

For a 2-link planar arm this has a clean trigonometric (closed-form) solution. For a general 6-DOF arm, a closed-form solution exists only under special geometric conditions — the classic being a spherical wrist (three axes intersecting at a point, the Pieper condition). Break that condition, or add joints, and analytical IK evaporates. Then we go numerical.

The Jacobian

The Jacobian J(q)Rm×nJ(\mathbf q) \in \mathbb{R}^{m\times n} (mm task dimensions, nn joints) linearizes FK by relating joint velocities to end-effector velocity:

x˙=J(q)q˙,Jij=xiqj\dot{\mathbf x} = J(\mathbf q)\,\dot{\mathbf q}, \qquad J_{ij} = \frac{\partial x_i}{\partial q_j}

To step the tip toward the goal by Δx\Delta\mathbf x we want the joint step Δq\Delta\mathbf q solving Δx=JΔq\Delta\mathbf x = J\,\Delta\mathbf q. When JJ is square and invertible, Δq=J1Δx\Delta\mathbf q = J^{-1}\Delta\mathbf x. It almost never is.

When JJ is not invertible: pseudoinverse, damping, transpose

For non-square or rank-deficient JJ we use one of several estimators, each with a distinct failure mode:

  • Moore–Penrose pseudoinverse J=J(JJ)1J^\dagger = J^\top(JJ^\top)^{-1} gives the minimum-norm joint step — but blows up near singularities where JJJJ^\top becomes ill-conditioned.
  • Damped Least Squares (DLS / Levenberg–Marquardt):   Δq=J(JJ+λ2I)1Δx\;\Delta\mathbf q = J^\top(JJ^\top + \lambda^2 I)^{-1}\Delta\mathbf x. The damping λ\lambda trades accuracy for stability, taming singularities at the cost of small steady-state error.
  • Jacobian transpose Δq=αJΔx\Delta\mathbf q = \alpha J^\top \Delta\mathbf x requires no matrix inverse and behaves like gradient descent on 12e2\tfrac12\|\mathbf e\|^2 — cheap and robust, but slow to converge.

Singularities and manipulability

A singularity is a configuration where JJ loses rank: the arm can no longer move instantaneously in some task direction. We quantify proximity with Yoshikawa's manipulability index

w(q)=det ⁣(J(q)J(q))w(\mathbf q) = \sqrt{\det\!\big(J(\mathbf q)J(\mathbf q)^\top\big)}

which collapses to 00 at a singularity (think of an arm stretched fully straight — it cannot extend further). Production controllers monitor ww or the condition number κ(J)\kappa(J) and switch on damping as they approach trouble.

Python Implementation: Numerical IK Solver

Rather than hand-deriving the Jacobian, a robust route is to pose IK as nonlinear least squares and let an optimizer handle it.

Loading Interactive Python Environment...

Note this 3-link arm reaching a 2D target is already redundant: 3 joints, 2 constraints. The optimizer returns one of infinitely many solutions — which one depends on the initial guess. That redundancy is a curse for a 3-link toy and an existential challenge for a tentacle.

The competing IK families and where they break

MethodBest forShortcomings
Analytical (closed-form)Low-DOF arms with special geometryExists only for spherical-wrist / Pieper-type structures; no redundancy handling
Jacobian pseudoinverseGeneral redundant armsUnstable near singularities; minimum-norm bias may violate joint limits
Damped least squares (LM)Singularity-prone motionsDamping introduces steady-state error; λ\lambda needs tuning
Jacobian transposeCheap, embedded controllersSlow convergence; no metric guarantees
Cyclic Coordinate Descent (CCD)Long serial/hyper-redundant chainsGreedy; produces unnatural, joint-heavy poses
Optimization (SQP/IK as NLP)Constraints (limits, obstacles, posture)Local minima; cost per query; needs good seed
Learned IK (neural)Real-time, high-DOF, multimodalNeeds data; accuracy/extrapolation limits; can hallucinate infeasible poses

High-Dimensional vs. Low-Dimensional: Redundancy as the Dividing Line

For a low-DOF arm (n=mn = m, e.g. a 6-DOF arm reaching a 6-D pose), IK has a finite number of solutions — typically up to 8 for a 6R arm (elbow up/down, wrist flip, etc.). You enumerate them and pick one.

For a high-DOF (redundant, n>mn > m) robot, the solution set is a continuous (nm)(n-m)-dimensional manifold — infinitely many configurations reach the same point. This is simultaneously a gift (dexterity, obstacle avoidance, fault tolerance) and a curse (you must choose). The standard tool is null-space projection:

q˙=Jx˙  +  (IJJ)q˙0\dot{\mathbf q} = J^\dagger \dot{\mathbf x} \;+\; \big(I - J^\dagger J\big)\,\dot{\mathbf q}_0

The first term achieves the task; the second term lives in the null space of JJ and reshapes the arm without moving the tip — used to push toward q˙0=H(q)\dot{\mathbf q}_0 = \nabla H(\mathbf q), the gradient of a secondary objective HH (stay away from joint limits, maximize manipulability, dodge an obstacle). This is how a redundant robot scratches its elbow while keeping its hand still.

As nn \to \infty (a continuum arm), even this breaks down: the null space is infinite-dimensional, the Jacobian becomes an operator, and we must regularize with physically meaningful priors (minimum bending energy, smoothness). This is precisely why learning-based and energy-based methods (Part 7) increasingly replace classical IK for soft robots.

Focus on the Octopus: Reachability and Hyper-Redundancy

For a rigid robot, IK returns joint angles. For our metallic continuum octopus, IK is exponentially harder because a tentacle is hyper-redundant — theoretically infinite DOF — so there are infinitely many ways to reach any point.

We resolve this redundancy by adding secondary constraints to the cost, exactly as in the null-space formulation above: minimize total bending energy, avoid obstacles, or orient the suction cups in a chosen direction. Concretely, we solve

minq  FK(q)xtarget2reach the target  +  λE0Lκ(s)2dsbending energy  +  λoΦobstacle(q)\min_{\mathbf q}\; \underbrace{\|FK(\mathbf q) - \mathbf x_{target}\|^2}_{\text{reach the target}} \;+\; \lambda_E \underbrace{\textstyle\int_0^L \kappa(s)^2\,ds}_{\text{bending energy}} \;+\; \lambda_o\,\Phi_{obstacle}(\mathbf q)

Before deploying control we also run reachability analysis: executing the IK solver across a dense 3D grid (millions of queries) to map the exact workspace volume the tentacle can reach without violating its bending limits. For a 6-DOF arm this map is a tidy shell; for a tentacle it is a thick, soft-edged cloud whose boundary depends on the secondary objectives we chose — a vivid reminder that in high dimensions, the question "can you reach it?" has no answer until you say what else you care about.

In Part 4 we add mass, force, and acceleration, moving from kinematics to Dynamics.

Further reading: Buss (2004), "Introduction to Inverse Kinematics with Jacobian Transpose, Pseudoinverse and Damped Least Squares"; Nakamura (1991), "Advanced Robotics: Redundancy and Optimization"; Diffusion Policy (arXiv:2303.04137) for learning multimodal solutions where classical IK struggles.

Interested in the research?

We collaborate with researchers, engineers, and institutions pushing Physical AI into extreme environments. Get in touch to explore working with the lab.

Collaborate with us

Ensemble Assistant

Ready

Quick Actions: