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:
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:
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:
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:
This is iterated until convergence. Methods for computing J⁺:
- Moore-Penrose pseudoinverse: J⁺ = Jᵀ(JJᵀ)⁻¹ — exact but expensive and unstable near singularities
- Damped least squares (DLS): J⁺ = Jᵀ(JJᵀ + λ²I)⁻¹ — adds damping factor λ to prevent blown-up solutions at singularities
- Transpose method: δθ = Jᵀ · δx — no inversion needed; slower convergence but robust. Good for real-time applications.
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:
- Forward pass: Move the end-effector to the target. Then re-position each joint to maintain link lengths, working backward toward the root.
- Backward pass: Fix the root at its original position. Re-position each joint forward to maintain link lengths.
- 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
- Industrial robots: 6-DOF arms (KUKA, ABB, Fanuc) use analytical IK for real-time trajectory planning at 1 kHz control loops
- Surgical robots: da Vinci uses IK with joint limits to map surgeon hand movements to small-scale end-effector motions
- Game characters: IK foot placement on uneven terrain, hand reaching for objects, head/eye tracking
- VR avatars: Full-body IK from head + hand trackers (3 inputs → entire skeleton via constrained IK)
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.