🤖 Robotics · Animation
📅 Березень 2026⏱ 13 min🟡 Середній

Forward & Inverse Kinematics for Robot Arms

Forward kinematics asks "given joint angles, where is the end-effector?" Inverse kinematics asks the opposite — and it's vastly harder. Every industrial robot, game character, and surgical instrument relies on these two complementary problems.

1. FK vs IK: What & Why

Forward Kinematics (FK)

Input: Joint angles θ₁, θ₂, ... θₙ
Output: End-effector position (x, y, z) and orientation
Complexity: Always one unique solution. Direct trigonometric computation. O(n) for n joints.

Inverse Kinematics (IK)

Input: Desired end-effector position & orientation
Output: Joint angles θ₁, θ₂, ... θₙ
Complexity: May have 0, 1, or infinitely many solutions. Generally requires iterative solving. Non-linear.

FK is used for simulation and motion playback. IK is used for interactive control: "move the robot hand to this bolt" or "make the character reach for the doorknob". Most real-time systems combine both — FK for the body, IK for hands and feet.

2. Forward Kinematics in 2D

A 2D arm with n revolute joints: each joint i has angle θᵢ and link length Lᵢ. The position of joint k is the cumulative sum of link vectors:

x_k = Σᵢ₌₁ᵏ Lᵢ · cos(θ₁ + θ₂ + ... + θᵢ) y_k = Σᵢ₌₁ᵏ Lᵢ · sin(θ₁ + θ₂ + ... + θᵢ) End-effector (joint n): x_n = L₁·cos(θ₁) + L₂·cos(θ₁+θ₂) + ... + Lₙ·cos(Σθ) y_n = L₁·sin(θ₁) + L₂·sin(θ₁+θ₂) + ... + Lₙ·sin(Σθ)

This direct computation is always unique, always fast. For a 2-link arm: x = L₁·cos θ₁ + L₂·cos(θ₁+θ₂), y = L₁·sin θ₁ + L₂·sin(θ₁+θ₂).

3. Denavit–Hartenberg Parameters (3D)

In 3D, each joint is described by four DH parameters: link length a, link twist α, link offset d, and joint angle θ. The transformation from frame i−1 to frame i is:

Tᵢ = Rot_z(θᵢ) · Trans_z(dᵢ) · Trans_x(aᵢ) · Rot_x(αᵢ) [ cos θ −sin θ·cos α sin θ·sin α a·cos θ ] T = [ sin θ cos θ·cos α −cos θ·sin α a·sin θ ] [ 0 sin α cos α d ] [ 0 0 0 1 ] Total FK: T₀ₙ = T₁ · T₂ · T₃ · ... · Tₙ

The final column of T₀ₙ gives the end-effector position; the upper-left 3×3 submatrix gives its orientation. For a 6-DOF industrial arm (e.g. KUKA, UR5), this is a product of six 4×4 matrices.

4. Analytical Inverse Kinematics

For a 2-link 2D arm, IK has a closed-form solution using the law of cosines:

Given target (x_t, y_t): cos θ₂ = (x_t² + y_t² − L₁² − L₂²) / (2·L₁·L₂) θ₂ = ±arccos(cos θ₂) ← two solutions: "elbow up" and "elbow down" θ₁ = atan2(y_t, x_t) − atan2(L₂·sin θ₂, L₁ + L₂·cos θ₂) Reachable if |L₁ − L₂| ≤ √(x² + y²) ≤ L₁ + L₂

Industrial 6R robots (6 revolute joints with specific geometries) also admit analytical solutions — up to 16 possible configurations. These closed-form solutions are the fastest and most reliable when available, but they only exist for specific kinematic architectures.

5. Jacobian-Based IK

For general chains with no analytical solution, the Jacobian provides a linear relationship between small joint angle changes and small end-effector movements:

δx = J · δθ J is the m×n Jacobian matrix (m = task DOFs, n = joint DOFs) Jᵢⱼ = ∂xᵢ/∂θⱼ IK update: δθ = J⁺ · δx (J⁺ = pseudoinverse of J) θ_new = θ_old + α · J⁺ · (x_target − x_current)

This is iterated until convergence. Methods for computing J⁺:

6. CCD & FABRIK

Cyclic Coordinate Descent (CCD)

Process each joint one at a time, from end-effector to root. For each joint, rotate it so the end-effector moves maximally toward the target. Repeat for several cycles. Simple, fast, but can converge to unnatural poses.

FABRIK (Forward And Backward Reaching IK)

A heuristic that works directly with joint positions, not angles:

  1. Forward pass: Move the end-effector to the target. Then re-position each joint to maintain link lengths, working backward toward the root.
  2. Backward pass: Fix the root at its original position. Re-position each joint forward to maintain link lengths.
  3. Repeat until convergence (typically 3–10 iterations, often <1 ms).
function fabrik(joints, target, tolerance) {
  const n = joints.length;
  const linkLengths = [];
  for (let i = 0; i < n - 1; i++)
    linkLengths[i] = distance(joints[i], joints[i + 1]);

  while (distance(joints[n - 1], target) > tolerance) {
    // Forward: end-effector to root
    joints[n - 1] = target;
    for (let i = n - 2; i >= 0; i--) {
      const dir = normalize(sub(joints[i], joints[i + 1]));
      joints[i] = add(joints[i + 1], scale(dir, linkLengths[i]));
    }
    // Backward: root to end-effector
    joints[0] = rootPos; // fix root
    for (let i = 1; i < n; i++) {
      const dir = normalize(sub(joints[i], joints[i - 1]));
      joints[i] = add(joints[i - 1], scale(dir, linkLengths[i - 1]));
    }
  }
}

FABRIK is the most popular IK method in games and procedural animation due to its speed, simplicity, and natural-looking results.

7. Applications & Constraints

Real-world IK always includes joint constraints: angular limits (a human elbow bends 0°–145°, not 360°), collision avoidance, and singularity handling. Production IK solvers (Unity's Animation Rigging, Unreal's IK Rig) combine FABRIK with constraint projection and blending layers.

Redundancy: When a chain has more DOFs than the task requires (e.g. 7 joints for a 6D target), the system is redundant — infinitely many solutions exist. The null space of J can be used to satisfy secondary objectives (avoid obstacles, minimize energy, stay away from joint limits) while still reaching the target.