1. Home
  2. Explore
  3. Engineering
  4. Inverse Kinematics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Inverse Kinematics

Inverse Kinematics

Problem Definition and Overview

Inverse kinematics addresses the practical problem of determining the joint variables required to achieve a desired position and orientation of a robot's end-effector (tool). Unlike forward kinematics, where joint angles are known and the resulting tool pose is computed, inverse kinematics starts with a desired tool pose and asks: What joint angles produce this pose?

Inverse Kinematics Problem: Given a desired position PPP and orientation RRR of the tool, find values for the joint variables qqq (e.g., θ1,θ2,…\theta_1, \theta_2, \dotsθ1​,θ2​,…) that satisfy the arm equation Tn0(q)=[R(q)P(q)01]T^0_n(q) = \begin{bmatrix} R(q) & P(q) \\ 0 & 1 \end{bmatrix}Tn0​(q)=[R(q)0​P(q)1​].

In practical applications — such as picking an object from one location and placing it at another — the task is defined by the desired position and orientation of the tool. The joint angles needed to reach that pose are unknown, making inverse kinematics essential for robot programming. See the diagram: the robot must bring its end-effector to the object's location and orientation to grasp it.


Relationship Between Forward and Inverse Kinematics

  • Forward (Direct) Kinematics: Maps joint space variables q=(q1,…,qn)q = (q_1, \dots, q_n)q=(q1​,…,qn​) to tool configuration space — position P=(Px,Py,Pz)P = (P_x, P_y, P_z)P=(Px​,Py​,Pz​) and orientation RRR (rotation matrix). Given qqq, we compute PPP and RRR.

  • Inverse Kinematics: Maps tool configuration space (P,R)(P, R)(P,R) back to joint space qqq. This is the inverse mapping and is generally more complex.

The arm matrix (homogeneous transformation) from forward kinematics provides the equations that must be solved for the inverse problem. Without the forward kinematic relationship, inverse kinematics cannot be solved.


Solvability of Inverse Kinematics

Not every desired pose can be achieved; the inverse problem may have no solution, one solution, or multiple solutions. Several conditions determine solvability.

Necessary Conditions for Existence of a Solution

For a solution to exist, the following necessary conditions must be satisfied:

  1. The desired tool point must lie within the robot's workspace.
    If the position is beyond the reachable region, no joint configuration can achieve it.

  2. The number of degrees of freedom nnn must be at least 6 for arbitrary orientation.

    • Positioning requires 3 degrees of freedom (x,y,zx, y, zx,y,z).

    • Orientation requires 3 degrees of freedom (roll, pitch, yaw).

    • If n<6n < 6n<6, not all orientations can be achieved; the missing orientation degrees of freedom become dependent. For example, a 5-DOF robot can reach any position within its workspace, but orientation will be constrained by the two remaining joints.

  3. The desired tool orientation must not violate any joint limits.
    Physical robots have limited joint ranges (e.g., a wrist pitch may only rotate ±90∘\pm 90^\circ±90∘). If the required orientation exceeds these limits, no solution exists even if the position is reachable.


Multiple Solutions

Inverse kinematics rarely yields a unique solution. Common sources of multiplicity include:

  • Elbow-up / Elbow-down configurations: For a planar arm, the same end-effector position can be reached with the elbow bending upward or downward (two distinct joint angle sets).

  • Redundant robots: When n>6n > 6n>6 (redundant degrees of freedom), there are infinitely many joint configurations for a given pose. For example, a 7-DOF robot has one extra joint; the solution requires fixing one variable arbitrarily, leading to multiple solutions.

  • Wrist configurations: Wrist singularities and alternative wrist orientations (e.g., flip vs. no-flip) can produce multiple angle sets.

Key point: Because of multiple solutions, the inverse problem is inherently more difficult than the forward problem, which always has a unique output for given joint angles.


Number of Independent Equations

The arm matrix Tn0T^0_nTn0​ contains 12 scalar equations (9 from rotation, 3 from position). However, the rotation matrix's 9 elements are not independent:

  • Each column (normal n\mathbf{n}n, sliding s\mathbf{s}s, approach a\mathbf{a}a vectors) is a unit vector: ∥n∥=1\|\mathbf{n}\| = 1∥n∥=1, ∥s∥=1\|\mathbf{s}\| = 1∥s∥=1, ∥a∥=1\|\mathbf{a}\| = 1∥a∥=1.

  • These three vectors are mutually orthogonal: n⋅s=0\mathbf{n} \cdot \mathbf{s} = 0n⋅s=0, n⋅a=0\mathbf{n} \cdot \mathbf{a} = 0n⋅a=0, s⋅a=0\mathbf{s} \cdot \mathbf{a} = 0s⋅a=0.

Thus, from the 9 rotation equations, only 3 independent equations exist (typically the three orthonormality constraints). The position vector gives 3 independent equations (Px,Py,PzP_x, P_y, P_zPx​,Py​,Pz​).

  • Total independent equations: 3+3=63 + 3 = 63+3=6.

  • Unknown joint variables: nnn (typically 6 for a 6-DOF robot).

If n=6n = 6n=6, we have 6 equations in 6 unknowns — solvable in principle. If n>6n > 6n>6, the system is underdetermined (multiple solutions). If n<6n < 6n<6, some orientations cannot be achieved.


Solution Strategies

Two main approaches exist for solving inverse kinematics.

Closed-Form (Analytical) Solutions

Closed-form solutions use algebraic or geometric methods to obtain explicit expressions for joint variables. They are preferred because they are fast, accurate, and provide all possible solutions.

  • Algebraic approach: Derive scalar equations from the arm matrix and solve them using trigonometric identities and algebraic manipulations.

  • Geometric approach: Use geometric reasoning — consider the geometry of the arm (link lengths, joint axes) to find joint angles by constructing triangles and computing angles from known positions.

Sufficiency condition for closed-form solutions: A closed-form solution exists if the manipulator satisfies one of the following:

  1. Three adjacent joint axes are parallel (e.g., a spherical wrist with parallel roll-pitch-yaw axes).

  2. Three adjacent joint axes intersect at a common point (e.g., the wrist center of a PUMA-type robot).

If neither condition holds, closed-form solution is generally not possible, and numerical methods must be used.

Numerical (Iterative) Solutions

Numerical methods start with an initial guess for joint angles and iteratively adjust them until the resulting tool pose matches the desired pose within a tolerance. These are:

  • Slower than closed-form methods.

  • Time-consuming and may converge to local minima.

  • Used when closed-form solution does not exist or when the robot is redundant.


Algebraic Tricks for Solving Inverse Kinematics

The scalar equations from the arm matrix are nonlinear and involve sine and cosine functions. Several tricks simplify solving them.

Trick 1: Square and Add Equations

For equations of the form:

Px=L1cos⁡θ1+L2cos⁡(θ1+θ2)P_x = L_1 \cos\theta_1 + L_2 \cos(\theta_1+\theta_2)Px​=L1​cosθ1​+L2​cos(θ1​+θ2​)
Py=L1sin⁡θ1+L2sin⁡(θ1+θ2)P_y = L_1 \sin\theta_1 + L_2 \sin(\theta_1+\theta_2)Py​=L1​sinθ1​+L2​sin(θ1​+θ2​)

Square both and add:

Px2+Py2=L12+L22+2L1L2cos⁡θ2P_x^2 + P_y^2 = L_1^2 + L_2^2 + 2 L_1 L_2 \cos\theta_2Px2​+Py2​=L12​+L22​+2L1​L2​cosθ2​

This eliminates θ1\theta_1θ1​ and yields an expression for cos⁡θ2\cos\theta_2cosθ2​, from which θ2\theta_2θ2​ can be found (using sin⁡θ2=±1−cos⁡2θ2\sin\theta_2 = \pm\sqrt{1-\cos^2\theta_2}sinθ2​=±1−cos2θ2​​).

Trick 2: Use the Tangent Half-Angle Substitution

Substitute u=tan⁡(θ/2)u = \tan(\theta/2)u=tan(θ/2). Then:

sin⁡θ=2u1+u2,cos⁡θ=1−u21+u2\sin\theta = \frac{2u}{1+u^2}, \quad \cos\theta = \frac{1-u^2}{1+u^2}sinθ=1+u22u​,cosθ=1+u21−u2​

This converts trigonometric equations into polynomial equations in uuu, which can be solved for uuu, then θ=2arctan⁡u\theta = 2\arctan uθ=2arctanu.

Trick 3: Combine Equations into Acos⁡θ+Bsin⁡θ=C\mathbf{A}\cos\theta + \mathbf{B}\sin\theta = \mathbf{C}Acosθ+Bsinθ=C Form

When an equation takes the form Acos⁡θ+Bsin⁡θ=CA \cos\theta + B \sin\theta = CAcosθ+Bsinθ=C, it can be solved by:

  • Letting r=A2+B2r = \sqrt{A^2 + B^2}r=A2+B2​ and γ=atan2(B,A)\gamma = \text{atan2}(B, A)γ=atan2(B,A).

  • Then Acos⁡θ+Bsin⁡θ=rcos⁡(θ−γ)=CA \cos\theta + B \sin\theta = r \cos(\theta - \gamma) = CAcosθ+Bsinθ=rcos(θ−γ)=C, giving θ=γ±arccos⁡(C/r)\theta = \gamma \pm \arccos(C/r)θ=γ±arccos(C/r).

Trick 4: Obtain Both sin⁡θ\sin\thetasinθ and cos⁡θ\cos\thetacosθ and Use atan2\text{atan2}atan2

If expressions for both sin⁡θ\sin\thetasinθ and cos⁡θ\cos\thetacosθ can be found, use the four-quadrant arctangent function atan2(sin⁡θ,cos⁡θ)\text{atan2}(\sin\theta, \cos\theta)atan2(sinθ,cosθ) to get θ\thetaθ uniquely in (−π,π](-\pi, \pi](−π,π]. This avoids quadrant ambiguity present with arcsin⁡\arcsinarcsin or arccos⁡\arccosarccos alone.

Definition of atan2\text{atan2}atan2: atan2(y,x)\text{atan2}(y, x)atan2(y,x) returns the angle whose sine is yyy and cosine is xxx, determining the correct quadrant from the signs of xxx and yyy. The result lies in (−π,π](-\pi, \pi](−π,π].


Example 1: 2-DOF Planar Manipulator

A simple planar arm with two revolute joints, link lengths L1L_1L1​ and L2L_2L2​. Forward kinematics gives:

Px=L1cos⁡θ1+L2cos⁡(θ1+θ2)P_x = L_1 \cos\theta_1 + L_2 \cos(\theta_1+\theta_2)Px​=L1​cosθ1​+L2​cos(θ1​+θ2​)
Py=L1sin⁡θ1+L2sin⁡(θ1+θ2)P_y = L_1 \sin\theta_1 + L_2 \sin(\theta_1+\theta_2)Py​=L1​sinθ1​+L2​sin(θ1​+θ2​)

Goal: Solve for θ1\theta_1θ1​, θ2\theta_2θ2​ given PxP_xPx​, PyP_yPy​.

Step 1: Solve for θ2\theta_2θ2​. Square and add the equations:

Px2+Py2=L12+L22+2L1L2cos⁡θ2P_x^2 + P_y^2 = L_1^2 + L_2^2 + 2 L_1 L_2 \cos\theta_2Px2​+Py2​=L12​+L22​+2L1​L2​cosθ2​
cos⁡θ2=Px2+Py2−L12−L222L1L2\cos\theta_2 = \frac{P_x^2 + P_y^2 - L_1^2 - L_2^2}{2 L_1 L_2}cosθ2​=2L1​L2​Px2​+Py2​−L12​−L22​​

Then sin⁡θ2=±1−cos⁡2θ2\sin\theta_2 = \pm \sqrt{1 - \cos^2\theta_2}sinθ2​=±1−cos2θ2​​ (two possible signs). Use atan2\text{atan2}atan2:

θ2=atan2(sin⁡θ2,cos⁡θ2)\theta_2 = \text{atan2}(\sin\theta_2, \cos\theta_2)θ2​=atan2(sinθ2​,cosθ2​)

Step 2: Solve for θ1\theta_1θ1​. Rewrite the original equations:

Px=L1cos⁡θ1+L2cos⁡(θ1+θ2)=(L1+L2cos⁡θ2)cos⁡θ1−(L2sin⁡θ2)sin⁡θ1P_x = L_1 \cos\theta_1 + L_2 \cos(\theta_1+\theta_2) = (L_1 + L_2 \cos\theta_2)\cos\theta_1 - (L_2 \sin\theta_2)\sin\theta_1Px​=L1​cosθ1​+L2​cos(θ1​+θ2​)=(L1​+L2​cosθ2​)cosθ1​−(L2​sinθ2​)sinθ1​
Py=L1sin⁡θ1+L2sin⁡(θ1+θ2)=(L1+L2cos⁡θ2)sin⁡θ1+(L2sin⁡θ2)cos⁡θ1P_y = L_1 \sin\theta_1 + L_2 \sin(\theta_1+\theta_2) = (L_1 + L_2 \cos\theta_2)\sin\theta_1 + (L_2 \sin\theta_2)\cos\theta_1Py​=L1​sinθ1​+L2​sin(θ1​+θ2​)=(L1​+L2​cosθ2​)sinθ1​+(L2​sinθ2​)cosθ1​

Define:

K1=L1+L2cos⁡θ2,K2=L2sin⁡θ2K_1 = L_1 + L_2 \cos\theta_2, \quad K_2 = L_2 \sin\theta_2K1​=L1​+L2​cosθ2​,K2​=L2​sinθ2​

Then:

Px=K1cos⁡θ1−K2sin⁡θ1P_x = K_1 \cos\theta_1 - K_2 \sin\theta_1Px​=K1​cosθ1​−K2​sinθ1​
Py=K1sin⁡θ1+K2cos⁡θ1P_y = K_1 \sin\theta_1 + K_2 \cos\theta_1Py​=K1​sinθ1​+K2​cosθ1​

Let r=K12+K22r = \sqrt{K_1^2 + K_2^2}r=K12​+K22​​, γ=atan2(K2,K1)\gamma = \text{atan2}(K_2, K_1)γ=atan2(K2​,K1​). Then:

Px=rcos⁡(γ+θ1),Py=rsin⁡(γ+θ1)P_x = r \cos(\gamma + \theta_1), \quad P_y = r \sin(\gamma + \theta_1)Px​=rcos(γ+θ1​),Py​=rsin(γ+θ1​)

Therefore:

γ+θ1=atan2(Py,Px)\gamma + \theta_1 = \text{atan2}(P_y, P_x)γ+θ1​=atan2(Py​,Px​)
θ1=atan2(Py,Px)−atan2(K2,K1)\theta_1 = \text{atan2}(P_y, P_x) - \text{atan2}(K_2, K_1)θ1​=atan2(Py​,Px​)−atan2(K2​,K1​)

This gives θ1\theta_1θ1​ for each of the two possible θ2\theta_2θ2​ values, yielding up to two distinct solutions (elbow-up and elbow-down).


Example 2: 3-DOF Planar Manipulator with Prismatic Joint

Consider a planar arm with two revolute joints (θ1\theta_1θ1​, θ2\theta_2θ2​) and one prismatic joint (d3d_3d3​) that extends vertically out of the plane. Link lengths: L1L_1L1​, L2L_2L2​; prismatic displacement d3d_3d3​. Forward kinematics yields:

Position:

Px=L1cos⁡θ1+L2cos⁡(θ1+θ2)P_x = L_1 \cos\theta_1 + L_2 \cos(\theta_1+\theta_2)Px​=L1​cosθ1​+L2​cos(θ1​+θ2​)
Py=L1sin⁡θ1+L2sin⁡(θ1+θ2)P_y = L_1 \sin\theta_1 + L_2 \sin(\theta_1+\theta_2)Py​=L1​sinθ1​+L2​sin(θ1​+θ2​)
Pz=d3P_z = d_3Pz​=d3​

Orientation (rotation matrix)

R=[cos⁡(θ1+θ2+θ3)−sin⁡(θ1+θ2+θ3)0sin⁡(θ1+θ2+θ3)cos⁡(θ1+θ2+θ3)0001]R = \begin{bmatrix} \cos(\theta_1+\theta_2+\theta_3) & -\sin(\theta_1+\theta_2+\theta_3) & 0 \\ \sin(\theta_1+\theta_2+\theta_3) & \cos(\theta_1+\theta_2+\theta_3) & 0 \\ 0 & 0 & 1 \end{bmatrix}R=​cos(θ1​+θ2​+θ3​)sin(θ1​+θ2​+θ3​)0​−sin(θ1​+θ2​+θ3​)cos(θ1​+θ2​+θ3​)0​001​​

Thus nx=cos⁡(θ123)n_x = \cos(\theta_{123})nx​=cos(θ123​), ny=sin⁡(θ123)n_y = \sin(\theta_{123})ny​=sin(θ123​), sx=−sin⁡(θ123)s_x = -\sin(\theta_{123})sx​=−sin(θ123​), sy=cos⁡(θ123)s_y = \cos(\theta_{123})sy​=cos(θ123​).

Goal: Solve for θ1\theta_1θ1​, θ2\theta_2θ2​, θ3\theta_3θ3​, d3d_3d3​ given PxP_xPx​, PyP_yPy​, PzP_zPz​ and orientation (nxn_xnx​, nyn_yny​, sxs_xsx​, sys_ysy​). Note that d3=Pzd_3 = P_zd3​=Pz​ directly.

Step 1: Solve for θ2\theta_2θ2​ exactly as in the 2-DOF case (square and add PxP_xPx​, PyP_yPy​ equations):

cos⁡θ2=Px2+Py2−L12−L222L1L2,sin⁡θ2=±1−cos⁡2θ2\cos\theta_2 = \frac{P_x^2 + P_y^2 - L_1^2 - L_2^2}{2 L_1 L_2}, \quad \sin\theta_2 = \pm\sqrt{1-\cos^2\theta_2}cosθ2​=2L1​L2​Px2​+Py2​−L12​−L22​​,sinθ2​=±1−cos2θ2​​
θ2=atan2(sin⁡θ2,cos⁡θ2)\theta_2 = \text{atan2}(\sin\theta_2, \cos\theta_2)θ2​=atan2(sinθ2​,cosθ2​)

Step 2: Solve for θ1\theta_1θ1​ using the same substitution as in the 2-DOF case:

K1=L1+L2cos⁡θ2,K2=L2sin⁡θ2,r=K12+K22K_1 = L_1 + L_2 \cos\theta_2, \quad K_2 = L_2 \sin\theta_2, \quad r = \sqrt{K_1^2 + K_2^2}K1​=L1​+L2​cosθ2​,K2​=L2​sinθ2​,r=K12​+K22​​
γ=atan2(K2,K1)\gamma = \text{atan2}(K_2, K_1)γ=atan2(K2​,K1​)
θ1=atan2(Py,Px)−γ\theta_1 = \text{atan2}(P_y, P_x) - \gammaθ1​=atan2(Py​,Px​)−γ

Step 3: Solve for θ123=θ1+θ2+θ3\theta_{123} = \theta_1 + \theta_2 + \theta_3θ123​=θ1​+θ2​+θ3​. Using nxn_xnx​ and nyn_yny​:

cos⁡(θ123)=nx,sin⁡(θ123)=ny\cos(\theta_{123}) = n_x, \quad \sin(\theta_{123}) = n_ycos(θ123​)=nx​,sin(θ123​)=ny​
θ123=atan2(ny,nx)\theta_{123} = \text{atan2}(n_y, n_x)θ123​=atan2(ny​,nx​)

Step 4: Solve for θ3\theta_3θ3​:

θ3=θ123−θ1−θ2\theta_3 = \theta_{123} - \theta_1 - \theta_2θ3​=θ123​−θ1​−θ2​

This yields all joint variables. Note the multiple solutions: each θ2\theta_2θ2​ (positive or negative sine) gives a different θ1\theta_1θ1​ and consequently θ3\theta_3θ3​, typically producing two distinct arm configurations.


Summary of Key Concepts

  • Inverse kinematics is essential for practical robot control: given a desired tool pose, find joint angles.

  • Solution existence depends on workspace, sufficient DOF (≥6 for arbitrary pose), and joint limit constraints.

  • Multiple solutions arise from elbow-up/down, wrist flips, and redundancy (DOF > 6).

  • Closed-form solutions are preferred and possible if three adjacent joint axes are parallel or intersect.

  • Algebraic tricks (square-and-add, half-angle substitution, atan2\text{atan2}atan2, rcos⁡(θ−γ)r\cos(\theta-\gamma)rcos(θ−γ) form) are used to solve nonlinear trigonometric equations.

  • The atan2\text{atan2}atan2 function uniquely determines an angle in (−π,π](-\pi, \pi](−π,π] from sin⁡\sinsin and cos⁡\coscos values, avoiding quadrant ambiguity.

Inverse kinematics remains a challenging but fundamental topic in robotics, requiring both mathematical insight and careful handling of multiple solutions and constraints.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent