Forward Kinematics and Denavit-Hartenberg Parameters
DH parameters are a compact notation — but they hide enough subtleties that a single sign error silently breaks the entire kinematic chain.
🎯 By the end you'll understand
What a DH parameter is and what each of the four numbers represents geometrically. How to build the homogeneous transform for a single joint from those four numbers. How to compose the chain of transforms to get the end-effector pose in the base frame. How to assign DH frames to FollowBot's 6-DOF arm and compute its rest-pose FK. Why DH frame assignment is not unique — and why that ambiguity can silently produce a wrong Jacobian. The workspace shape that results from FollowBot's link lengths and joint limits.
KEY INSIGHTOne convention to describe every serial chain
A robot arm is a sequence of rigid links connected by joints. The only question FK asks is: given the joint angles right now, where is the tip? The Denavit-Hartenberg convention answers it with exactly four numbers per joint — no more, no less.
Forward kinematics (FK) is the mapping from joint space to task space: given a vector of joint angles q = [q₁, q₂, …, qn], compute the 4×4 homogeneous transform T₀ₙ that gives the end-effector's position and orientation in the base frame. It is a function of geometry only — no forces, no accelerations, no uncertainty. What makes it interesting in practice is not the math (it's matrix multiplication) but the bookkeeping: where do you attach the coordinate frames, and in what order do you multiply?
The position and orientation of the end-effector are physical facts. They don't depend on how you chose to attach frames. But the Jacobian — the matrix that tells you how joint velocities map to tip velocities — does depend on frame assignment in the sense that each column is expressed in a specific frame. Two engineers who assign DH frames differently will get the same end-effector pose from FK, but their Jacobians will look different and can produce different inverse-kinematics solutions. The lesson: always verify FK against a geometric calculation before you trust any downstream computation.
DEFINITIONThe four DH parameters — what each one does geometrically
In 1955, Jacques Denavit and Richard Hartenberg published a systematic way to attach coordinate frames to the links of a serial chain such that each link-to-link transform requires only four numbers. Those four numbers are the DH parameters.
The convention places frame i on link i, with its z-axis along joint i+1's axis of rotation (for a revolute joint). The four parameters describe the transform from frame i-1 to frame i:
| Parameter | Symbol | Geometric meaning | Variable? |
|---|---|---|---|
| Link offset | d | Distance along zi-1 from origin of frame i-1 to the common normal | Yes, for prismatic joints |
| Joint angle | θ | Rotation about zi-1 from xi-1 to the common normal | Yes, for revolute joints |
| Link length | a | Distance along the common normal from zi-1 to zi | No — fixed geometry |
| Link twist | α | Rotation about the common normal from zi-1 to zi | No — fixed geometry |
In a revolute joint (the common case in robot arms), the joint variable is θ. The arm rotates about the z-axis of the previous frame. In a prismatic joint (a linear slide), the joint variable is d — the link telescopes along z. FollowBot's 6-DOF arm has six revolute joints; all six θ values change during motion and all d, a, α values are fixed by the physical design of the arm.
HOW IT WORKSBuilding one joint's homogeneous transform
Given the four DH parameters for joint i, the transform from frame i-1 to frame i is a composition of four elementary transforms applied in a specific order. This order is the DH convention — it is not negotiable once you commit to it:
Rotate about zi-1 by θᵢ
Align the x-axis of frame i-1 with the common normal. This is the joint rotation — the motion the motor actually produces. For revolute joints, θᵢ = θᵢ,offset + qᵢ where qᵢ is the encoder reading.
Translate along zi-1 by dᵢ
Move from the origin of frame i-1 to the foot of the common normal — the point where the common normal meets zi-1. For most revolute-only arms, dᵢ is a fixed distance (the link's axial offset). For prismatic joints this is the variable.
Translate along xi-1 by aᵢ
Move along the common normal from zi-1 to zi. This is the link length — the physical distance between adjacent joint axes measured perpendicularly to both.
Rotate about xi-1 by αᵢ
Twist the frame to align zi-1 with zi. This encodes whether the next joint's axis is parallel, perpendicular, or at some other angle to the current one. A 90° twist makes adjacent axes perpendicular — common in wrist designs.
These four elementary transforms compose into one 4×4 homogeneous matrix, which you can verify by expanding the product Rot(z,θ)·Trans(z,d)·Trans(x,a)·Rot(x,α):
import numpy as np def dh_transform(theta, d, a, alpha): """ Return the 4x4 homogeneous DH transform T_{i-1,i}. Parameters ---------- theta : float joint angle (radians); the revolute joint variable d : float link offset along z_{i-1} a : float link length along common normal alpha : float link twist (radians) rotating z_{i-1} toward z_i """ ct, st = np.cos(theta), np.sin(theta) ca, sa = np.cos(alpha), np.sin(alpha) return np.array([ [ct, -st*ca, st*sa, a*ct], [st, ct*ca, -ct*sa, a*st], [ 0, sa, ca, d], [ 0, 0, 0, 1], ])
The top-left 3×3 block is the rotation from frame i-1 to frame i. The right column (top three rows) is the origin of frame i expressed in frame i-1. Bottom row is the projective homogeneous row — always [0,0,0,1] for a rigid transform. This is exactly the result derived in Lesson 1.2 for homogeneous transforms composed from rotation and translation.
Set all joint angles to zero (θᵢ = 0 for all i). Each DH matrix becomes purely a function of the constant geometry: d, a, α. The resulting T₀ₙ should reproduce the robot's known rest-pose geometry — a length you can measure with a ruler. If it doesn't, one of your d, a, or α values is wrong. This is the first test to run after you've written down the DH table, before you ever vary any joint angle.
CORE CONCEPTComposing the chain: from base to end-effector
For an n-joint serial arm, you build one DH matrix per joint and left-multiply them in order:
import numpy as np def forward_kinematics(dh_params, q): """ FK for an n-DOF serial arm with pure revolute joints. dh_params: list of (d, a, alpha) for each joint — constant geometry q: list of joint angles in radians (length n) Returns T_0n — end-effector pose in base frame (4x4). """ T = np.eye(4) for (d, a, alpha), theta in zip(dh_params, q): T = T @ dh_transform(theta, d, a, alpha) return T # Example: 3-DOF planar arm, all joints in same plane (alpha=0 throughout) dh = [ (0.0, 0.25, 0.0), # joint 1: d=0, a=0.25m, alpha=0 (0.0, 0.20, 0.0), # joint 2 (0.0, 0.15, 0.0), # joint 3 ] q = [np.pi/4, np.pi/6, -np.pi/3] T = forward_kinematics(dh, q) print("End-effector position [m]:", T[:3, 3]) print("End-effector rotation:\n", T[:3, :3])
The result T₀ₙ is the end-effector's pose in the base frame (frame 0). T₀ₙ[:3, 3] gives the Cartesian position. T₀ₙ[:3, :3] gives the rotation matrix — which you can convert to Euler angles or a quaternion using the conversions from Lesson 1.3.
The DH product is always T₀ₙ = T₀₁ · T₁₂ · … · T_{n-1,n}. Each Tᵢ₋₁,ᵢ describes the transform from the previous frame to the next, so you left-multiply the accumulator by the next matrix: T = T @ Tᵢ. If you right-multiply by accident, you express each sub-transform in the end-effector frame rather than the base frame — a subtle error that produces numerically valid but physically nonsensical results. The Python convention above (T = T @ new) is correct.
You can also extract intermediate poses: T₀ₖ = T₀₁ · T₁₂ · … · Tₖ₋₁,ₖ gives the position of joint k's origin in the base frame. This is exactly what you need for workspace visualization and for each column of the Jacobian (covered in Lesson 2.4).
SEE ITDH chain builder — set parameters, watch the frame chain
Below is a 4-joint revolute arm. Each joint has four DH sliders: θ (joint angle), d, a, and α. Use the presets to load known configurations, then sweep joint 1 to see exactly what motion you'd expect from that geometry. The zero-check panel tells you whether the rest-pose tip position matches the sum of link lengths — the first sanity check every roboticist runs.
FOLLOWBOTFollowBot's 6-DOF arm: DH table and rest-pose FK
FollowBot carries a 6-DOF serial manipulator mounted on the mobile base — a compact arm used for handoff operations and gesture recognition. The arm has three shoulder joints (establishing reach), a forearm joint (elbow), and a two-axis wrist. Here are the DH parameters for a representative arm geometry consistent with FollowBot's design — link lengths chosen to give a usable workspace from a ~1 m mounted height:
| Joint | θᵢ (°, zero pos.) | dᵢ (m) | aᵢ (m) | αᵢ (°) | Role |
|---|---|---|---|---|---|
| 1 — shoulder yaw | 0 | 0.100 | 0 | 90 | Rotates arm about vertical axis; α=90° makes next z horizontal |
| 2 — shoulder pitch | 0 | 0 | 0.280 | 0 | Upper arm link (0.28 m); brings arm forward |
| 3 — elbow | 0 | 0 | 0.240 | 0 | Forearm link (0.24 m); shares plane with joint 2 |
| 4 — forearm roll | 0 | 0 | 0 | 90 | Rolls the forearm; α=90° transitions to wrist axes |
| 5 — wrist pitch | 0 | 0.160 | 0 | -90 | Wrist up/down; α=−90° completes wrist mechanism |
| 6 — wrist roll | 0 | 0.060 | 0 | 0 | End-effector rotation; d=60 mm to tool flange |
At all θᵢ = 0, the arm points straight forward with joints 2 and 3 fully extended. The tip x-position should equal a₂ + a₃ = 0.280 + 0.240 = 0.520 m from the shoulder (not from the base — d₁ adds 0.100 m vertically). The wrist offset (d₅ + d₆ = 0.160 + 0.060 = 0.220 m) adds along z₄ — which at zero configuration is the same as x of the base. Verify with: T₀₆[:3,3] ≈ [0.740, 0, 0.100]. If you get anything else, your frame assignments are wrong.
The ROS 2 side of FK is handled by the robot_state_publisher node, which reads joint states from /joint_states and publishes the corresponding transforms to the TF2 tree. You do not recompute FK in your Python nodes — you ask TF2:
import rclpy from rclpy.node import Node from tf2_ros import Buffer, TransformListener from rclpy.time import Time class ArmFKQuery(Node): def __init__(self): super().__init__('arm_fk_query') self.tf_buf = Buffer() self.tf_listener = TransformListener(self.tf_buf, self) # poll at 10 Hz self.create_timer(0.1, self.query_fk) def query_fk(self): try: # get transform from arm base to end-effector t = self.tf_buf.lookup_transform( 'arm_base_link', # reference frame 'arm_tool_link', # target frame (end-effector) Time() # latest available ) p = t.transform.translation self.get_logger().info( f'EE at [{p.x:.3f}, {p.y:.3f}, {p.z:.3f}] m' ) except Exception as e: self.get_logger().warn(f'TF lookup failed: {e}')
This is the correct ROS 2 pattern: robot_state_publisher runs the DH FK for you and publishes the results into TF2. Your nodes query TF2 rather than recomputing kinematics. The only time you compute FK explicitly in Python is during offline analysis or when you need it faster than TF2 can provide (which is rare on modern hardware).
The Stage 2 milestone adds the arm FK to FollowBot's ROS graph. The URDF specifies the DH geometry through joint origins and axes; robot_state_publisher subscribes to /joint_states and broadcasts the chain to TF2. The singularity monitor (Lesson 2.4) then reads these transforms at 50 Hz and warns when the Jacobian determinant drops below a threshold.
CORE CONCEPTWorkspace visualization: what FK tells you about reachability
FK also answers a subtler question: what region of space can the end-effector actually reach? This is the workspace — and it is shaped entirely by the link lengths and joint limits.
The reachable workspace is the set of all positions that the tip can reach with at least one configuration. The dexterous workspace is the subset it can reach in all orientations. For a 6-DOF arm the two are generally different — there are positions the arm can reach but only with a specific wrist orientation.
For a planar arm with n links and joint angles with no limits, the workspace is an annulus: inner radius = |a₁ - a₂ - … - aₙ|, outer radius = a₁ + a₂ + … + aₙ. Joint limits, link offsets (d parameters), and non-zero twist angles (α ≠ 0) deform this into the irregular solid of revolution you see in full 3D workspace plots. The computation is straightforward: sample the joint space on a grid, run FK at each sample, plot the resulting tip positions. You don't need to invert anything — FK is a closed-form calculation that runs in microseconds.
WEAKNESSWhere DH parameters bite
DH frame assignment requires choices: which direction is zi? The convention says zi must lie along joint i+1's axis, but that axis has two directions (pointing up or down). Different textbooks and different robot manufacturers make different choices. Two engineers can follow the DH convention correctly and produce different DH tables for the same physical arm. Both tables produce the same end-effector pose from FK — but each column of their Jacobians is expressed in a different frame, so the Jacobians will not be numerically identical. If you combine one engineer's DH table with another's Jacobian code, the robot will move in wrong directions under velocity control. The fix: always verify FK with a geometric measurement first, and document your frame-assignment choices explicitly.
DH requires a unique common normal between adjacent joint axes. When two joint axes are parallel, the common normal is not unique — there are infinitely many perpendicular lines connecting them, and you can place it anywhere along the axis. This makes the d parameter ambiguous. Some textbooks handle this with a special case (assign the common normal at the origin of the previous frame); others switch to the modified DH (MDH) or Craig DH convention. Many industrial robot manuals use MDH. If you use standard DH parameters copied from a manual that uses MDH (or vice versa), your FK will be numerically wrong — usually by one sign flip in a rotation that is easy to miss until the robot collides with something. Always identify which DH variant a table uses before you implement it.
A common shortcut: "My FK matches the simulator's pose." But if you imported your URDF into the simulator using the same DH table, the simulator and your FK agree by construction — both may be wrong. The only ground-truth check is geometric: measure the robot. Set θ₁ = 90° and verify with a level and ruler that the arm rotated exactly 90° about the expected axis, by the expected amount. Set all θᵢ = 0 and measure the tip position with a tape measure. A 5 mm discrepancy at the tip usually means one link length parameter (a or d) is wrong by a factor of 10 — a unit mismatch (mm vs. m) is the most common cause.
KEY INSIGHTHow this connects
- 1.2 · Coordinate Frames and Homogeneous Transforms — the 4×4 matrix algebra that DH builds on: what homogeneous transforms represent, how to compose them, what the top-left 3×3 block means. The DH matrix is nothing more than four elementary homogeneous transforms composed in a specific order.
- 1.3 · Rotation Representations: Matrices, Euler Angles, and Quaternions — once you have T₀ₙ, you need to extract the orientation. The rotation matrix T₀ₙ[:3,:3] is the starting point; Lesson 1.3 shows how to convert it to Euler angles (with their gimbal-lock pathology) or a quaternion (for ROS 2 messages).
- 2.2 · Wheel Odometry: Integration, Drift, and Dead Reckoning — the mobile base kinematic model that FK feeds into. The arm's end-effector position in world frame = T_world_base · T_base_armbase · T₀₆. All three transforms live in TF2; composing them is Lesson 2.2's odom integration expressed in the same matrix language.
- 2.4 · The Jacobian: Velocity Kinematics and the Spine of Robotics — the natural successor: given FK, take its derivative with respect to joint angles to get the Jacobian. Every column of the Jacobian is derived from the intermediate transforms T₀ₖ you've already computed. Lesson 2.4 builds the Jacobian directly from the DH chain.
Forward kinematics is the necessary first step in a chain: FK → Jacobian → inverse kinematics → trajectory planning. But it is also the checksum for everything else. If your Jacobian is wrong, FK will tell you. If your IK is wrong, FK of the solution will tell you. Roboticists compute FK constantly — in tests, in validators, in visualizers — precisely because it is the one closed-form, always-correct reference every other computation can be checked against.
GLOSSARYKey terms introduced
- Forward kinematics (FK)
- The mapping from joint configuration q to end-effector pose T₀ₙ in the base frame. A closed-form function of joint angles and link geometry; no forces or accelerations involved.
- Denavit-Hartenberg (DH) parameters
- A set of four numbers per joint (θ, d, a, α) that, when composed through the DH matrix formula, produce the homogeneous transform from one link frame to the next. First published by Denavit and Hartenberg in 1955.
- Link offset (d)
- The DH parameter measuring distance along zi-1 from the previous frame origin to the foot of the common normal. The joint variable for prismatic joints.
- Link length (a)
- The DH parameter measuring distance along the common normal between two adjacent joint axes. Determines physical arm reach in the absence of joint offsets.
- Link twist (α)
- The DH parameter measuring the angle between adjacent joint axes (zi-1 and zi) measured about the common normal. Zero for planar arms; ±90° for wrist-type joints.
- Common normal
- The unique line segment perpendicular to both adjacent z-axes. Its length is the link length a; its direction is xi-1 in the DH frame assignment. Undefined (non-unique) when adjacent axes are parallel.
- Reachable workspace
- The set of all tip positions the arm can achieve with at least one joint configuration. Computed by sampling joint space and running FK; shaped by link lengths, joint limits, and α values.
- Modified DH (MDH)
- A variant of the DH convention (attributed to Craig, 1986) in which frames are attached differently — zi lies along joint i's axis rather than joint i+1's. Produces different DH tables and different Jacobian forms for the same physical robot. Industrial robot manuals often use MDH; check which convention applies before implementing.
ACTIVE RECALLCheck your understanding
Answer in your own words first, then reveal.
1A 4-DOF planar arm has links a₁ = 0.25 m, a₂ = 0.20 m, a₃ = 0.15 m, a₄ = 0.10 m and all other DH parameters zero. At zero configuration, where is the end-effector, and what does this tell you about the zero-pose sanity check?›
At zero configuration with all θᵢ = 0, all rotations in the DH matrix become identity and each matrix contributes only a translation along x by aᵢ. The composed transform gives end-effector position x = 0.25 + 0.20 + 0.15 + 0.10 = 0.70 m, y = 0, z = 0 in the base frame. The sanity check: compare this to the sum of all link lengths (Σaᵢ = 0.70 m). If the FK value matches, you haven't made a transcription error in your a or d parameters. If it doesn't match, some geometry parameter is wrong — and this check catches it before you ever run a motion. Unit errors (mm entered as m) show up immediately here.
2Why does a non-zero α value in a DH table change the plane of motion of downstream joints, and what physical structure does α = 90° typically represent?›
The α parameter rotates the frame about the common normal (xi-1), which physically rotates zi relative to zi-1. Since joint i+1 rotates about zi, a twist in α changes the axis about which the next joint rotates. For α = 0, adjacent joints share the same plane of rotation (the planar arm case). For α = 90°, zi is perpendicular to zi-1 — joint i+1 rotates in a plane orthogonal to joint i. This is the physical structure of a wrist transition: after the shoulder and elbow joints (α = 0, planar chain), a 90° twist introduces the wrist pitch axis. Without understanding α, you'll set it to 0 everywhere and be confused when your simulated arm sweeps in the wrong plane.
3Two engineers assign DH frames to the same 6-DOF arm and get different DH tables — both follow the convention correctly. They both run FK at the same joint angles and get the same end-effector position. Is there any real difference between their tables?›
Yes — a significant one. The FK end-effector position will match because it is a physical quantity, invariant to frame choice. However, the end-effector orientation expressed as a rotation matrix may differ by a constant rotation offset (a rotation that depends on how the z-axes were signed). More critically, the Jacobians will differ: each column of the Jacobian is the cross product of zi (from the frame assignment) with the vector from joint i to the tip. Different zi directions give different Jacobian columns. This means velocity commands in task space — and IK solutions computed via the Jacobian — will produce different joint velocities and potentially different configurations. If you mix one engineer's FK frame with another engineer's Jacobian code, the velocity controller will move the robot in the wrong direction. Always verify FK against physical measurement before trusting downstream computations.
4In ROS 2, why do you query TF2 for the arm's end-effector pose rather than computing FK yourself from the joint angles?›
Because robot_state_publisher already runs FK from the URDF (which encodes the same link geometry as your DH table) and broadcasts the full kinematic chain to TF2 at every joint_states update. If you compute FK separately in your Python node, you introduce a parallel computation that may diverge from the published TF tree — due to timing mismatches, numerical differences, or a bug in your implementation. Querying TF2 via tf_buf.lookup_transform('arm_base_link', 'arm_tool_link', Time()) gives you the canonically correct transform that every other node in the system also uses, with consistent timestamps. The only valid reason to compute FK directly in Python is offline analysis (workspace visualization, IK validation) or a hard real-time path where TF2's latency is unacceptable — rare in practice for arm kinematics at 10–50 Hz.