# Module 1.4: Forward Kinematics

- Course: [Course 1: Frames, Transform Networks & Intro to Kinematics](https://roboticsconcepts.dev/courses/frames-transform-networks-kinematics.md)
- HTML Page: https://roboticsconcepts.dev/courses/frames-transform-networks-kinematics/forward-kinematics/
- Key Concepts: Chaining joint transforms, 2-link & 3-link planar arms, Reachable workspace & end-effector pose

Every motor on a robot arm has an encoder telling you its current joint angle. Forward Kinematics (FK) answers the everyday question: given those joint angles, where did the gripper actually end up in space?

## Two equivalent views: triangles vs. chained frames

For a simple 2-link arm in the plane, you don't even need matrices to see what's happening. Link 1 leans at angle θ₁, contributing (L₁ cos θ₁, L₁ sin θ₁). Link 2 attaches at the elbow and turns an extra θ₂, so its world angle is (θ₁ + θ₂) and it contributes (L₂ cos(θ₁ + θ₂), L₂ sin(θ₁ + θ₂)). Add the two triangles together and you have the gripper's position.

The neat part is that walking the TF tree from base to tool by multiplying T₀¹ · T₁² gives the exact same (x, y) numbers — except matrix multiplication scales effortlessly to 3-link arms, 6-DOF arms, and branched humanoids without drawing giant pages of triangles.

## Interactive Sandbox: Forward Kinematics & Point-of-View Frame Switcher

Turn on Triangle projections in the sandbox below, then switch between 2-Link and 3-Link mode. Watch how the dashed red and green legs add up directly to the end-effector's (x, y) coordinate.

## Workspace envelopes and full pose

Toggle the Workspace overlay and adjust L₁ and L₂. When L₁ and L₂ are equal, the arm can fold all the way back onto its own shoulder, filling a solid disk of radius L₁ + L₂. When one link is longer than the other, a hollow dead-zone circle appears right around the base where the tip physically cannot reach.

Notice too that FK gives you more than just tip position (x, y) — it also gives you the gripper's orientation φ = θ₁ + θ₂ (+ θ₃). With only 2 links, reaching a specific (x, y) locks your orientation automatically. Add the 3rd link and suddenly you can hold the gripper horizontal while raising or lowering your elbow.

## Planar 2-link forward kinematics

```text
x = L₁ cos(θ₁) + L₂ cos(θ₁ + θ₂),   y = L₁ sin(θ₁) + L₂ sin(θ₁ + θ₂),   φ = θ₁ + θ₂
```

Forward kinematics is always unique and fast to compute: one set of joint angles produces exactly one end-effector pose.

## Check Your Intuition

**Question:** A 2-link planar arm has link lengths L₁ = 1.2 m and L₂ = 0.5 m. What is the closest distance to its shoulder base that the tip can reach?

- [ ] 0.0 m — it can always touch its own base
- [✓] 0.7 m — the difference |L₁ - L₂|
- [ ] 1.7 m — the sum L₁ + L₂

**Explanation:** When the arm folds completely back on itself (θ₂ = ±180°), the tip lands at distance |L₁ - L₂| = 0.7 m from the shoulder.

## Where You'll See This in Modern Robotics

Simulators like MuJoCo and Isaac run forward kinematics on every single physics step to figure out where every link, collision capsule, and wrist camera sits in the world before checking contacts or rendering pixels.

## Companion Python Notebook: 04 · Forward Kinematics: Triangles vs. Chained SE(2)

Compare closed-form right-triangle trig against chained 3×3 homogeneous transforms for 2-link and 3-link arms, and plot joint-limited workspaces.

- Open in molab (WASM): https://molab.marimo.io/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/course-1/04_forward_kinematics.py/wasm
- Open in Google Colab: https://colab.research.google.com/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/colab/course-1/04_forward_kinematics.ipynb
- Download .py: https://roboticsconcepts.dev/downloads/notebooks/course-1/04_forward_kinematics.py
- Download .ipynb: https://roboticsconcepts.dev/downloads/notebooks/colab/course-1/04_forward_kinematics.ipynb
- Run locally: `uvx marimo edit --sandbox notebooks/course-1/04_forward_kinematics.py`
