Chapter 6: Inverse Kinematics (IK)

Lesson 2: Analytical IK for Common Arm Geometries

This lesson develops closed-form inverse kinematics (IK) for widely used manipulator geometries: planar 2R arms, 3R positioning arms, and 6R manipulators with spherical wrists. We derive the necessary trigonometric relations, discuss existence and multiplicity of solutions, and show how structural decoupling into position and orientation simplifies IK. Implementation examples in Python, C++, Java, MATLAB/Simulink, and Wolfram Mathematica are provided for planar arms, preparing the ground for more general numerical methods in later lessons.

1. Analytical IK and Structural Decoupling

For a manipulator with joint configuration vector \( \boldsymbol{\theta} \in \mathbb{R}^n \) and end-effector pose \( \mathbf{T}(\boldsymbol{\theta}) \in SE(3) \), the inverse kinematics problem asks for all joint vectors that satisfy

\[ \mathbf{T}(\boldsymbol{\theta}) = \begin{bmatrix} \mathbf{R}(\boldsymbol{\theta}) & \mathbf{p}(\boldsymbol{\theta}) \\ \mathbf{0}^T & 1 \end{bmatrix} = \mathbf{T}_d = \begin{bmatrix} \mathbf{R}_d & \mathbf{p}_d \\ \mathbf{0}^T & 1 \end{bmatrix}. \]

An analytical IK solution expresses each joint angle as an explicit algebraic function of the desired pose: \( \theta_i = f_i(\mathbf{R}_d, \mathbf{p}_d) \), typically using trigonometric and algebraic manipulations. Closed-form IK is feasible only for special structures (e.g., planar arms, spherical wrists), but when it exists, it is:

  • Exact (up to floating-point error),
  • Fast (no iteration required),
  • Explicit about solution multiplicity and singularities.

For many industrial 6R arms, the kinematic design admits decoupling of position and orientation. Let joint indices \(1,2,3\) form the positioning arm and \(4,5,6\) form a spherical wrist whose axes intersect at a single point. Then the IK problem is solved in two steps:

  1. Compute the wrist center position \( \mathbf{p}_w \) from \( \mathbf{T}_d \).
  2. Solve a 3R positioning problem for joints \(1,2,3\), then a 3R orientation problem for joints \(4,5,6\).
flowchart TD
  A["Desired pose T_d (R_d, p_d)"] --> B["Compute wrist center p_w = p_d - R_d * o_6"]
  B --> C["Solve 3R position IK for joints 1..3"]
  C --> D["Compute R_3_6 = R_3_0^T * R_d"]
  D --> E["Solve 3R orientation IK for joints 4..6"]
  E --> F["Assemble all joint solutions theta = [theta1..theta6] with branches"]
        

Before tackling 6R arms, we first derive a complete analytical IK solution for the planar 2R arm, which appears as a substructure in many manipulators and illustrates the trigonometric techniques used in more complex geometries.

2. Planar 2R Arm IK – Geometric Derivation

Consider a planar 2R manipulator with link lengths \( l_1, l_2 > 0 \) and joint angles \( \theta_1, \theta_2 \) measured from the standard \(x\)-axis. The end-effector position is

\[ \mathbf{p}(\theta_1,\theta_2) = \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} l_1\cos\theta_1 + l_2\cos(\theta_1+\theta_2) \\ l_1\sin\theta_1 + l_2\sin(\theta_1+\theta_2) \end{bmatrix}. \]

Given a desired planar target \( \mathbf{p}_d = [x_d \; y_d]^T \), IK asks for all \( (\theta_1,\theta_2) \) such that \( \mathbf{p}(\theta_1,\theta_2) = \mathbf{p}_d \). Define the distance from the base to the target

\[ r^2 = x_d^2 + y_d^2. \]

From elementary geometry, the arm can reach \( \mathbf{p}_d \) iff the target lies inside the annulus defined by link lengths:

\[ (l_1 - l_2)^2 \le r^2 \le (l_1 + l_2)^2. \]

To derive an explicit solution, we apply the law of cosines to the triangle formed by \( l_1, l_2 \), and \( r \). The interior angle opposite side \( l_2 \) is \( \pi - \theta_2 \), so

\[ r^2 = l_1^2 + l_2^2 - 2 l_1 l_2 \cos(\pi - \theta_2) = l_1^2 + l_2^2 + 2l_1 l_2 \cos\theta_2. \]

Solving for \( \cos\theta_2 \) yields

\[ \cos\theta_2 = \frac{r^2 - l_1^2 - l_2^2}{2 l_1 l_2}. \]

Real solutions require \( \left|\cos\theta_2\right| \le 1 \), which is equivalent to the reachability condition above. There are generally two solutions for \( \theta_2 \):

\[ \theta_2^{(\pm)} = \operatorname{atan2}\!\Big(\pm\sqrt{1-\cos^2\theta_2},\, \cos\theta_2\Big), \]

where the \(+\) branch corresponds to the elbow-up configuration and the \(-\) branch to the elbow-down configuration.

To solve for \( \theta_1 \), consider the projection of the second link onto the line from the base to the target. Define the auxiliary angles

\[ \phi = \operatorname{atan2}(y_d, x_d), \qquad \psi^{(\pm)} = \operatorname{atan2}\!\Big( l_2 \sin\theta_2^{(\pm)},\, l_1 + l_2\cos\theta_2^{(\pm)} \Big). \]

Then the two corresponding solutions for the first joint angle are

\[ \theta_1^{(\pm)} = \phi - \psi^{(\pm)}. \]

Altogether, the analytical IK for the planar 2R arm yields up to two distinct solutions \( (\theta_1^{(+)},\theta_2^{(+)}) \) and \( (\theta_1^{(-)},\theta_2^{(-)}) \), which merge into a single solution when the arm is fully stretched or fully folded (singular configurations).

3. 3R Positioning Arms – Spatial Extension of 2R Geometry

Many industrial arms use three proximal revolute joints to position a wrist center \( \mathbf{p}_w \in \mathbb{R}^3 \) in space. Common examples include RRR configurations with either all three axes mutually orthogonal, or two axes parallel and one orthogonal.

Suppose the Denavit–Hartenberg (DH) parameters for joints \(1,2,3\) are known and the forward kinematics from base frame \( \{0\} \) to frame \( \{3\} \) is

\[ \mathbf{T}_{0}^{3}(\theta_1,\theta_2,\theta_3) = \begin{bmatrix} \mathbf{R}_{0}^{3}(\theta_1,\theta_2,\theta_3) & \mathbf{p}_{0}^{3}(\theta_1,\theta_2,\theta_3) \\ \mathbf{0}^T & 1 \end{bmatrix}. \]

For decoupled 6R arms, the IK for the first three joints is solved from \( \mathbf{p}_{0}^{3}(\theta_1,\theta_2,\theta_3) = \mathbf{p}_w \), where \( \mathbf{p}_w \) is computed from the desired end-effector pose (see Section 4). For many designs, \( \mathbf{p}_{0}^{3} \) can be expressed in a form that reduces to a 2R planar problem in some projection.

As a canonical example, consider a positioning structure where joint 1 rotates about the global \(z\)-axis, and joints 2 and 3 actuate an arm in a plane that is vertical when viewed from the side. Let

\[ \mathbf{p}_w = \begin{bmatrix} x_w \\ y_w \\ z_w \end{bmatrix}, \qquad \rho = \sqrt{x_w^2 + y_w^2}. \]

Then \( \theta_1 \) is determined by projecting onto the \(x\)-\(y\) plane:

\[ \theta_1 = \operatorname{atan2}(y_w, x_w), \]

while joints \( \theta_2, \theta_3 \) solve a planar 2R problem in the plane defined by \( \rho \) and \( z_w \). That is, with effective link lengths \( L_2, L_3 \) and the target point \( (\rho, z_w) \), we reuse the 2R formulas from Section 2:

\[ \cos\theta_3 = \frac{\rho^2 + z_w^2 - L_2^2 - L_3^2}{2 L_2 L_3}, \qquad \theta_2 = \operatorname{atan2}(z_w, \rho) - \operatorname{atan2}\!\Big( L_3 \sin\theta_3,\, L_2 + L_3 \cos\theta_3 \Big), \]

with the same \( \pm \) branching as in the planar 2R case. This illustrates a recurring pattern: spatial IK often reduces to planar subproblems when the mechanism exhibits structural symmetries.

4. Analytic IK for 6R Arms with Spherical Wrist

A spherical wrist means that the last three joint axes intersect at a single point (the wrist center) and are mutually orthogonal (or otherwise arranged so that they span all 3D rotations). For such manipulators, we define:

  • \( \mathbf{o}_6 \): vector from the wrist center to the tool frame origin, expressed in frame \(\{6\} \),
  • \( \mathbf{R}_d \), \( \mathbf{p}_d \): desired end-effector rotation and position.

The wrist center in base coordinates is

\[ \mathbf{p}_w = \mathbf{p}_d - \mathbf{R}_d \mathbf{o}_6. \]

Step 1 (Position IK). Use \( \mathbf{p}_w \) to solve for joints \( \theta_1, \theta_2, \theta_3 \) via the 3R positioning IK from Section 3, obtaining a finite set of candidate triplets \( (\theta_1^{(k)},\theta_2^{(k)},\theta_3^{(k)}) \).

Step 2 (Orientation IK). For each candidate positioning solution, compute the resulting rotation \( \mathbf{R}_{0}^{3}(\theta_1^{(k)},\theta_2^{(k)},\theta_3^{(k)}) \) and define the wrist rotation:

\[ \mathbf{R}_{3}^{6}(\theta_4,\theta_5,\theta_6) = \mathbf{R}_{0}^{3}(\theta_1^{(k)},\theta_2^{(k)},\theta_3^{(k)})^T \mathbf{R}_d. \]

Because joints \(4,5,6\) form a 3R wrist, \( \mathbf{R}_{3}^{6} \) can be interpreted as the rotation parameterized by the three wrist angles. For example, in a common \(z\)-\(y\)-\(z\) wrist parameterization,

\[ \mathbf{R}_{3}^{6}(\theta_4,\theta_5,\theta_6) = \mathbf{R}_z(\theta_4)\mathbf{R}_y(\theta_5)\mathbf{R}_z(\theta_6), \]

where each element of \( \mathbf{R}_{3}^{6} \) is a known trigonometric function of the unknowns \( \theta_4, \theta_5, \theta_6 \). Matching this product with the numerically computed matrix \( \mathbf{R}_{3}^{6} \) yields scalar equations. A standard sequence of manipulations (analogous to Euler angle extraction) gives:

\[ \theta_5 = \operatorname{atan2}\!\Big( \sqrt{(r_{13})^2 + (r_{23})^2},\, r_{33} \Big), \]

\[ \theta_4 = \operatorname{atan2}(r_{23}, r_{13}), \qquad \theta_6 = \operatorname{atan2}(r_{32}, -r_{31}), \]

where \( r_{ij} \) are entries of the numerically known matrix \( \mathbf{R}_{3}^{6} \). Depending on the wrist parameterization and sign conventions, alternative extraction formulas may be used but follow the same pattern: one joint angle comes from an off-diagonal block magnitude, the others from atan2 of suitable entries.

Altogether, combining the branches from the 3R positioning IK (typically up to four solutions) with the branches from the wrist orientation IK (typically up to two solutions) yields up to \(8\) distinct analytical IK solutions for a generic 6R arm with a spherical wrist, ignoring joint limits and excluding singularities.

5. Solution Branches, Redundancies, and Singular Configurations

Analytical IK exposes the structure of multiple solutions as combinations of discrete choices. Even non-redundant arms (with 6 DOF) typically admit several branches:

  • Shoulder configurations (e.g., left vs. right),
  • Elbow configurations (e.g., up vs. down),
  • Wrist configurations (e.g., flipped vs. non-flipped).

For the planar 2R arm, the two branches are distinguished by the sign of \( \sin\theta_2 \). For spatial arms, similar signs appear in square roots or atan2 operations. Conceptually, each sign choice corresponds to a discrete branch in a solution tree:

flowchart TD
  ROOT["Solve position IK (3R)"] --> S1["theta1 choice (e.g., left/right)"]
  S1 --> E1["theta2, theta3 elbow-up"]
  S1 --> E2["theta2, theta3 elbow-down"]
  E1 --> W1["wrist orientation \nbranch 1"]
  E1 --> W2["wrist orientation \nbranch 2"]
  E2 --> W3["wrist orientation \nbranch 1"]
  E2 --> W4["wrist orientation \nbranch 2"]
        

Singularities appear when these branches merge or become undefined. For instance, the planar 2R arm is singular when \( \sin\theta_2 = 0 \), i.e., \( \theta_2 = 0 \) or \( \theta_2 = \pi \), corresponding to collinear links. In spherical wrists, singularities occur when the wrist loses one rotational DOF, e.g., when \( \theta_5 = 0 \) and the \(z\)-axes of joints 4 and 6 align.

Analytic formulas therefore not only provide exact solutions but also furnish explicit algebraic tests for singular configurations that will be used later in workspace and manipulability analysis.

6. Python Implementation for Planar 2R IK

In Python, analytical IK for a planar 2R arm can be implemented directly using numpy. For more complex robots, one may rely on robotics libraries such as the Robotics Toolbox for Python or ikpy, but here we illustrate a minimal from-scratch implementation.


import numpy as np

def ik_2r(x, y, l1, l2, tol=1e-9):
    """
    Analytical IK for a planar 2R arm.
    Returns a list of solution tuples (theta1, theta2).
    Angles are in radians.
    """
    r2 = x**2 + y**2
    # Reachability check
    if r2 > (l1 + l2)**2 + tol or r2 < (l1 - l2)**2 - tol:
        return []  # no real solutions

    # cos(theta2)
    c2 = (r2 - l1**2 - l2**2) / (2.0 * l1 * l2)
    # Numerical clipping for robustness
    c2 = np.clip(c2, -1.0, 1.0)
    # two possible s2 signs
    s2_candidates = [np.sqrt(1.0 - c2**2), -np.sqrt(1.0 - c2**2)]

    phi = np.arctan2(y, x)
    solutions = []
    for s2 in s2_candidates:
        theta2 = np.arctan2(s2, c2)
        # atan2 term for projection of l2
        k1 = l1 + l2 * c2
        k2 = l2 * s2
        psi = np.arctan2(k2, k1)
        theta1 = phi - psi
        solutions.append((theta1, theta2))
    return solutions

if __name__ == "__main__":
    l1, l2 = 0.5, 0.4
    x_d, y_d = 0.6, 0.3
    sols = ik_2r(x_d, y_d, l1, l2)
    for i, (t1, t2) in enumerate(sols):
        print(f"Solution {i}: theta1 = {t1:.4f}, theta2 = {t2:.4f}")
      

This function explicitly returns both elbow-up and elbow-down configurations when they exist. Extending this approach to 3R positioners and 6R arms primarily involves additional trigonometric manipulation and careful handling of branch choices for each joint.

7. C++ Implementation and Robotics Libraries

In C++, analytical IK is often implemented in the context of robotics middleware such as ROS, with libraries like Orocos KDL or MoveIt. Below is a simple C++ function for 2R IK using only the standard library:


#include <cmath>
#include <vector>
#include <utility>

struct AnglePair {
    double theta1;
    double theta2;
};

std::vector<AnglePair> ik2R(double x, double y, double l1, double l2, double tol = 1e-9) {
    std::vector<AnglePair> sols;
    double r2 = x*x + y*y;
    if (r2 > (l1 + l2)*(l1 + l2) + tol || r2 < (l1 - l2)*(l1 - l2) - tol) {
        return sols; // empty
    }

    double c2 = (r2 - l1*l1 - l2*l2) / (2.0 * l1 * l2);
    if (c2 > 1.0) c2 = 1.0;
    if (c2 < -1.0) c2 = -1.0;

    double s2_abs = std::sqrt(std::max(0.0, 1.0 - c2*c2));
    double phi = std::atan2(y, x);

    for (double s2 : {s2_abs, -s2_abs}) {
        double theta2 = std::atan2(s2, c2);
        double k1 = l1 + l2 * c2;
        double k2 = l2 * s2;
        double psi = std::atan2(k2, k1);
        double theta1 = phi - psi;
        sols.push_back({theta1, theta2});
    }
    return sols;
}
      

For 6R manipulators, analytic solvers are often implemented as specialized C++ classes (e.g., PUMA or KUKA kinematics plugins in MoveIt), where the DH parameters are hard-coded and the derived formulas are applied branch by branch.

8. Java, MATLAB/Simulink, and Mathematica Implementations

8.1 Java Implementation

Java is less common in low-level robotics but is used in higher-level simulation frameworks and teaching tools. The following code shows a simple 2R IK method using java.lang.Math:


import java.util.ArrayList;
import java.util.List;

public class IK2R {
    public static class AnglePair {
        public double theta1;
        public double theta2;
        public AnglePair(double t1, double t2) {
            this.theta1 = t1;
            this.theta2 = t2;
        }
    }

    public static List<AnglePair> solve(double x, double y, double l1, double l2, double tol) {
        List<AnglePair> sols = new ArrayList<>();
        double r2 = x*x + y*y;
        if (r2 > (l1 + l2)*(l1 + l2) + tol || r2 < (l1 - l2)*(l1 - l2) - tol) {
            return sols;
        }
        double c2 = (r2 - l1*l1 - l2*l2) / (2.0 * l1 * l2);
        c2 = Math.max(-1.0, Math.min(1.0, c2));
        double s2Abs = Math.sqrt(Math.max(0.0, 1.0 - c2*c2));
        double phi = Math.atan2(y, x);

        double[] s2Options = new double[]{ s2Abs, -s2Abs };
        for (double s2 : s2Options) {
            double theta2 = Math.atan2(s2, c2);
            double k1 = l1 + l2 * c2;
            double k2 = l2 * s2;
            double psi = Math.atan2(k2, k1);
            double theta1 = phi - psi;
            sols.add(new AnglePair(theta1, theta2));
        }
        return sols;
    }
}
      

8.2 MATLAB Function and Simulink Usage

MATLAB provides a Robotics System Toolbox that includes general-purpose IK solvers, but analytical 2R IK is easily implemented directly and reused in Simulink via a MATLAB Function block:


function [theta1_solutions, theta2_solutions] = ik2R(x, y, l1, l2)
%IK2R Analytical IK for a planar 2R arm.
%   Returns two-column vectors of theta1 and theta2 (in radians).

r2 = x.^2 + y.^2;
theta1_solutions = [];
theta2_solutions = [];

if r2 > (l1 + l2)^2 || r2 < (l1 - l2)^2
    return; % no real solution
end

c2 = (r2 - l1^2 - l2^2) / (2*l1*l2);
c2 = max(-1,min(1,c2));
s2_abs = sqrt(max(0,1 - c2^2));

phi = atan2(y, x);

for s2 = [s2_abs, -s2_abs]
    theta2 = atan2(s2, c2);
    k1 = l1 + l2*c2;
    k2 = l2*s2;
    psi = atan2(k2, k1);
    theta1 = phi - psi;
    theta1_solutions(end+1,1) = theta1; %#ok<AGROW>
    theta2_solutions(end+1,1) = theta2; %#ok<AGROW>
end
      

In Simulink, this function can be wrapped in a MATLAB Function block that receives \(x, y\) and outputs the joint angles, allowing integration with dynamics blocks or trajectory generators covered in later chapters.

8.3 Wolfram Mathematica Implementation

Mathematica is well suited to symbolic derivation and verification of analytical IK formulas. The following code uses Solve to find symbolic solutions and then defines a numerical function:


(* Symbolic setup *)
Clear[x, y, l1, l2, theta1, theta2];
eqs = {
  x == l1 Cos[theta1] + l2 Cos[theta1 + theta2],
  y == l1 Sin[theta1] + l2 Sin[theta1 + theta2]
};

solSym = Solve[eqs, {theta1, theta2}, Reals];

(* Numeric wrapper *)
ik2R[xNum_, yNum_, l1Num_, l2Num_] := Module[
  {subs, sols},
  subs = {x -> xNum, y -> yNum, l1 -> l1Num, l2 -> l2Num};
  sols = ({theta1, theta2} /. solSym) /. subs;
  N[sols]
];

(* Example usage *)
ik2R[0.6, 0.3, 0.5, 0.4]
      

Symbolic computation can also be used to derive and simplify analytic IK for specific 6R manipulators, although the resulting expressions are often quite long and must be carefully implemented to ensure numerical stability.

9. Problems and Solutions

Problem 1 (Reachability for Planar 2R). A planar 2R arm has link lengths \( l_1 = 0.4 \,\text{m} \) and \( l_2 = 0.3 \,\text{m} \). Determine the exact set of planar points \( (x,y) \) reachable by the end-effector and prove your answer using geometric arguments.

Solution:

The distance from the base to the end-effector is \( r = \sqrt{x^2 + y^2} \). By the triangle inequality applied to the two links,

\[ |l_1 - l_2| \le r \le l_1 + l_2. \]

Squaring both sides gives the condition on \( r^2 = x^2 + y^2 \):

\[ (l_1 - l_2)^2 \le x^2 + y^2 \le (l_1 + l_2)^2. \]

With \( l_1 = 0.4 \) and \( l_2 = 0.3 \), we obtain

\[ (0.4 - 0.3)^2 = 0.01 \le x^2 + y^2 \le (0.4 + 0.3)^2 = 0.49. \]

Thus the reachable set is the closed annulus in the plane centered at the base with inner radius \(0.1\) and outer radius \(0.7\). Any point inside this annulus can be achieved with some joint angles because the two-link mechanism can form a triangle with side lengths \(l_1, l_2, r\) whenever the triangle inequalities hold; conversely, if the inequalities fail, no such triangle can be formed, so the point is unreachable.

Problem 2 (Explicit 2R IK Solutions). For a planar 2R arm with arbitrary positive link lengths \( l_1, l_2 \), derive the explicit formulas for \( \theta_1^{(\pm)} \) and \( \theta_2^{(\pm)} \) as functions of a desired point \( (x_d, y_d) \) and interpret the geometric meaning of each branch.

Solution:

From Section 2, set \( r^2 = x_d^2 + y_d^2 \). Under the reachability condition, the law of cosines yields

\[ \cos\theta_2 = \frac{r^2 - l_1^2 - l_2^2}{2 l_1 l_2}. \]

Hence

\[ \theta_2^{(\pm)} = \operatorname{atan2}\!\Big( \pm\sqrt{1-\cos^2\theta_2},\, \cos\theta_2 \Big). \]

Define \( \phi = \operatorname{atan2}(y_d,x_d) \), \( k_1 = l_1 + l_2 \cos\theta_2^{(\pm)} \), \( k_2 = l_2 \sin\theta_2^{(\pm)} \), and \( \psi^{(\pm)} = \operatorname{atan2}(k_2,k_1) \). Then

\[ \theta_1^{(\pm)} = \phi - \psi^{(\pm)}. \]

The \(+\) branch corresponds to the elbow pointing "above" the line from base to target, while the \(-\) branch corresponds to the elbow pointing "below" that line. Both configurations place the end-effector at the same point but with different arm postures.

Problem 3 (3R Positioner with Vertical Plane). Consider a 3R positioning arm in which joint 1 rotates about the global \(z\)-axis and joints 2 and 3 form a planar 2R arm in a vertical plane. Let the wrist center be \( \mathbf{p}_w = [x_w \; y_w \; z_w]^T \). Show that \( \theta_1 = \operatorname{atan2}(y_w,x_w) \) and derive the 2R-style equations for \( \theta_2 \) and \( \theta_3 \) in terms of \( \rho = \sqrt{x_w^2 + y_w^2} \) and \( z_w \).

Solution:

The projection of \( \mathbf{p}_w \) onto the base \(x\)-\(y\) plane defines \( \rho = \sqrt{x_w^2 + y_w^2} \) and the azimuth \( \theta_1 \) via

\[ \theta_1 = \operatorname{atan2}(y_w, x_w). \]

In the rotated frame where joint 1 defines the plane, the planar coordinates of the wrist center are \( (\rho, z_w) \). Assuming effective link lengths \( L_2, L_3 \) for joints 2 and 3, we have the planar equations

\[ \rho = L_2\cos\theta_2 + L_3\cos(\theta_2+\theta_3), \quad z_w = L_2\sin\theta_2 + L_3\sin(\theta_2+\theta_3), \]

which are exactly the planar 2R forward kinematics. Thus we reuse the formulas of Problem 2 with \( x_d \) replaced by \( \rho \), \( y_d \) replaced by \( z_w \), \( l_1 = L_2 \), \( l_2 = L_3 \), giving explicit analytic expressions for \( \theta_2 \) and \( \theta_3 \).

Problem 4 (Spherical Wrist Singularity). A spherical wrist with joints \(4,5,6\) arranged in a \(z\)-\(y\)-\(z\) configuration has rotation matrix \( \mathbf{R}_{3}^{6}(\theta_4,\theta_5,\theta_6) = \mathbf{R}_z(\theta_4)\mathbf{R}_y(\theta_5)\mathbf{R}_z(\theta_6) \). Show that when \( \theta_5 = 0 \), the wrist loses one degree of freedom, and explain how this manifests in the analytical IK formulas.

Solution:

When \( \theta_5 = 0 \), the middle rotation about the \(y\)-axis becomes the identity:

\[ \mathbf{R}_{3}^{6}(\theta_4,0,\theta_6) = \mathbf{R}_z(\theta_4)\mathbf{I}\mathbf{R}_z(\theta_6) = \mathbf{R}_z(\theta_4 + \theta_6). \]

Thus only the sum \( \theta_4 + \theta_6 \) is observable in the net rotation; individual values of \( \theta_4 \) and \( \theta_6 \) cannot be uniquely recovered. In the analytical IK extraction formulas, \( \theta_5 \) is obtained from expressions such as

\[ \theta_5 = \operatorname{atan2}\!\Big( \sqrt{(r_{13})^2 + (r_{23})^2},\, r_{33} \Big), \]

which becomes \( \theta_5 = 0 \) when the off-diagonal elements vanish. At this point, the formulas for \( \theta_4 \) and \( \theta_6 \) that rely on division by \( \sin\theta_5 \) or separate inspection of off-diagonal elements become ill-conditioned, reflecting the loss of an independent degree of freedom.

Problem 5 (Counting IK Solutions). Consider a non-redundant 6R arm with a spherical wrist where the 3R positioner (joints \(1,2,3\)) admits up to 4 IK solutions for a given wrist center and the 3R wrist admits up to 2 solutions for a given desired orientation. Assuming generic (non-singular) conditions and no joint limits, compute the maximum number of distinct IK solutions for the full 6R arm. Explain how these branches are organized.

Solution:

For each wrist center \( \mathbf{p}_w \), the 3R positioner may have up to 4 solutions arising from combinations of shoulder and elbow configurations. For each of these 4 solutions, the spherical wrist is generically a 3R structure that admits up to 2 distinct sets of angles satisfying the same orientation, corresponding to different internal wrist postures (e.g., wrist-flip vs. non-flip). Assuming independence of these choices, the total number of solutions is

\[ N_{\text{max}} = 4 \times 2 = 8. \]

These solutions can be organized in a tree as in Section 5, with the first branching level corresponding to shoulder choice, the second to elbow choice, and the final to wrist choice. Singularity and joint-limit constraints may reduce this count in practice.

10. Summary

In this lesson we developed analytical IK for common manipulator geometries. Starting from the planar 2R arm, we derived explicit trigonometric formulas for the joint angles and identified reachability and multiplicity of solutions. We extended the same geometric reasoning to 3R positioning structures and showed how spherical wrists enable a clean decoupling of position and orientation in 6R manipulators, yielding up to eight closed-form solutions in the generic case.

Implementation examples in Python, C++, Java, MATLAB/Simulink, and Wolfram Mathematica illustrated how these formulas can be translated into code suitable for simulation and control. The explicit expressions derived here will form the basis for the geometric IK techniques in the next lesson and will provide ground truth for evaluating numerical IK algorithms introduced later in the chapter.

11. References

  1. Pieper, D.L. (1968). The kinematics of manipulators under computer control. Ph.D. Dissertation, Stanford University.
  2. Paul, R.P. (1972). Modelling, trajectory calculation and servoing of a computer controlled arm. Ph.D. Dissertation, Stanford University.
  3. Roth, B., & Freudenstein, F. (1963). Synthesis of path-generating mechanisms by means of a programmed digital computer. ASME Journal of Engineering for Industry, 85(3), 298–306.
  4. Lee, C.S.G., & Liang, C. (1988). A systematic algorithm for solving the inverse kinematics of robot manipulators. IEEE Transactions on Robotics and Automation, 4(2), 165–175.
  5. Manocha, D., & Canny, J. (1994). Efficient inverse kinematics for general 6R manipulators. IEEE Transactions on Robotics and Automation, 10(5), 648–657.
  6. Wampler, C.W. (1996). Manipulator inverse kinematic solutions based on vector formulations and elementary solutions. IEEE Transactions on Systems, Man, and Cybernetics, 16(1), 93–101.
  7. Angeles, J., & Lopez-Cajun, C. (1992). Optimisation of Cam Mechanisms, Chapter on kinematic synthesis principles applied to manipulators.
  8. Raghavan, M., & Roth, B. (1993). Inverse kinematics of the general 6R manipulator and related linkages. ASME Journal of Mechanical Design, 115(3), 502–508.