Denavit-Hartenberg convention

How to attach frames by the Denavit-Hartenberg rules, read the four link parameters, build each link transform and multiply them for forward kinematics.

Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

To compute where a robot's tool is, you need a transform between every pair of neighbouring links. The Denavit-Hartenberg (DH) convention gives a systematic recipe: attach frames by fixed rules, read off just four numbers per joint, and the whole forward kinematics drops out as a product of standard matrices. Robot manufacturers, textbooks and university exams all describe arms through their DH tables.

Key ideas

Idea. A general frame-to-frame transform needs 6 numbers. DH reduces this to 4 parameters per link by choosing frames cleverly: the z-axis of each frame lies along a joint axis and each x-axis lies along the common normal between consecutive joint axes.

Frame assignment rules (standard / distal DH, as in Spong and most Indian syllabi):

  1. Number joints 1 … n and links 0 (base) … n. Joint i connects link i−1 to link i.
  2. Put z_{i−1} along the axis of joint i (rotation axis for R, sliding direction for P).
  3. Choose x_i along the common normal from z_{i−1} to z_i, pointing away from z_{i−1}. The origin o_i is where this normal meets z_i.
    • If z_{i−1} and z_i intersect, take x_i perpendicular to both (x_i = ±z_{i−1} × z_i); o_i at the intersection.
    • If they are parallel, the common normal is not unique; choose it to make as many d's zero as possible.
  4. y_i completes a right-handed frame. Frame 0 is the base (z_0 along joint 1); frame n is placed on the tool, usually with z_n along the approach direction.

The four parameters of link i:

  • θ_i (joint angle) — angle from x_{i−1} to x_i, measured about z_{i−1}. Variable for a revolute joint.
  • d_i (link offset) — distance from o_{i−1} to the x_i axis, measured along z_{i−1}. Variable for a prismatic joint.
  • a_i (link length) — distance between z_{i−1} and z_i, measured along x_i.
  • α_i (link twist) — angle from z_{i−1} to z_i, measured about x_i.

So each row of the DH table has exactly one variable (θ for R, d for P) and three constants. The link transform is a screw about z followed by a screw about x:

A_i = Rot(z, θ_i) · Trans(z, d_i) · Trans(x, a_i) · Rot(x, α_i)

and the forward kinematics is ⁰T_n = A_1 · A_2 · … · A_n.

Modified (proximal) DH (Craig) attaches frame i at joint i instead and uses the order Rot(x, α_{i−1})·Trans(x, a_{i−1})·Rot(z, θ_i)·Trans(z, d_i). Both are correct but do not mix them; always state which one a table uses.

Limitations. DH parameters become ill-conditioned for nearly parallel joint axes (small misalignment produces a huge jump in d), which is why calibration often uses modified parameter sets.

Formulas

A_i = Rot(z, θ_i) · Trans(z, d_i) · Trans(x, a_i) · Rot(x, α_i)

A_i = [[cos θ_i, −sin θ_i·cos α_i, sin θ_i·sin α_i, a_i·cos θ_i], [sin θ_i, cos θ_i·cos α_i, −cos θ_i·sin α_i, a_i·sin θ_i], [0, sin α_i, cos α_i, d_i], [0, 0, 0, 1]]

  • θ_i, α_i — angles (rad or °); a_i, d_i — lengths (m).

⁰T_n = A_1 · A_2 · … · A_n

  • Gives the tool-frame orientation (upper-left 3 × 3) and position (fourth column) in the base frame.

Planar 2R: x = a_1·cos θ_1 + a_2·cos(θ_1 + θ_2), y = a_1·sin θ_1 + a_2·sin(θ_1 + θ_2)

Worked examples

Example 1 (standard). Planar 2R arm, a_1 = 0.5 m, a_2 = 0.3 m, all α = 0, all d = 0. Write the DH table and find the tool position for θ_1 = 30°, θ_2 = 45°.

DH table (link: θ, d, a, α): 1: θ_1, 0, 0.5, 0 — 2: θ_2, 0, 0.3, 0.

  1. With α = 0, A_i = [[cos θ_i, −sin θ_i, 0, a_i·cos θ_i], [sin θ_i, cos θ_i, 0, a_i·sin θ_i], [0, 0, 1, 0], [0, 0, 0, 1]].
  2. A_1·A_2 gives x = a_1·cos θ_1 + a_2·cos(θ_1 + θ_2), y = a_1·sin θ_1 + a_2·sin(θ_1 + θ_2).
  3. x = 0.5·cos 30° + 0.3·cos 75° = 0.4330 + 0.0776 = 0.5107 m.
  4. y = 0.5·sin 30° + 0.3·sin 75° = 0.2500 + 0.2898 = 0.5398 m.
  5. Tool orientation: rotated θ_1 + θ_2 = 75° about z.

Answer: (0.511 m, 0.540 m), tool at 75°.

Example 2 (GATE level). A SCARA arm has DH table (θ, d, a, α): 1: θ_1, 0.40 m, 0.35 m, 0° — 2: θ_2, 0, 0.25 m, 180° — 3: 0, d_3, 0, 0°. Find the tool position for θ_1 = 30°, θ_2 = −60°, d_3 = 0.15 m.

  1. α_2 = 180° flips z_2 to point downward, so the prismatic joint d_3 moves the tool down.
  2. x = a_1·cos θ_1 + a_2·cos(θ_1 + θ_2) = 0.35·cos 30° + 0.25·cos(−30°) = 0.3031 + 0.2165 = 0.5196 m.
  3. y = a_1·sin θ_1 + a_2·sin(θ_1 + θ_2) = 0.35·0.5 + 0.25·(−0.5) = 0.175 − 0.125 = 0.050 m.
  4. z = d_1 − d_3 = 0.40 − 0.15 = 0.25 m.
  5. Multiplying A_1·A_2·A_3 numerically confirms the fourth column (0.5196, 0.050, 0.25) and z_3 = (0, 0, −1).

Answer: (0.520, 0.050, 0.250) m, tool pointing straight down.

Common mistakes

  • Putting z_i along joint i instead of joint i+1 (standard DH puts z_{i−1} on joint i).
  • Measuring θ about x or α about z — θ and d belong to z_{i−1}; a and α belong to x_i.
  • Marking the wrong variable: θ is variable for revolute joints, d for prismatic.
  • Getting the sign of α wrong — measure from z_{i−1} to z_i using the right-hand rule about x_i.
  • Mixing standard and modified DH tables or matrices.
  • Forgetting a constant offset in θ (e.g. θ_2 − 90°) when the zero position of the robot differs from the DH zero.

For GATE ME

Expect questions that give a DH table or a simple 2- or 3-link sketch and ask for the end-effector position, the number of variable parameters, or a single element of A_i. Practise filling DH tables for 2R planar, SCARA, cylindrical and a 3R articulated arm, and evaluating the planar 2R formula quickly.

Quick check

  1. How many DH parameters describe one link, and how many of them vary?
  2. Which DH parameter is the variable for a prismatic joint?
  3. About which axis is α_i measured?
  4. A 2R planar arm with a_1 = a_2 = 1 m has θ_1 = 0°, θ_2 = 90°. Tool position?
  5. What does α = 180° do to the next z-axis?

Answers: 1. Four, one variable; 2. d_i; 3. About x_i; 4. (1, 1) m; 5. Reverses it (points it the opposite way).

Try answering each one aloud before you open it.

  1. 1.What are the four Denavit-Hartenberg parameters and what does each one measure?Concept

    In standard DH, θᵢ is the angle from x_{i−1} to xᵢ about z_{i−1}, and dᵢ is the offset along z_{i−1} from o_{i−1} to the xᵢ axis. aᵢ is the link length, the distance between z_{i−1} and zᵢ along their common normal xᵢ, and αᵢ is the twist, the angle from z_{i−1} to zᵢ about xᵢ. For a revolute joint θᵢ is the variable; for a prismatic joint dᵢ is.

  2. 2.Why does DH need only four parameters per link when a general rigid transform needs six?Concept

    The frames are not placed arbitrarily: each z-axis is aligned with a joint axis and each x-axis lies along the common normal between successive z-axes, intersecting both. These two constraints remove two degrees of freedom from the frame-to-frame transform, so a rotation and translation about z followed by a rotation and translation about x are enough.

  3. 3.What is the difference between standard (distal) and modified (proximal) DH?Concept

    In standard DH (Spong, Paul) frame i is attached at the far end of link i, with z_{i−1} on joint i, and the link transform is Rot(z,θ)·Trans(z,d)·Trans(x,a)·Rot(x,α). In modified DH (Craig) frame i is attached at joint i, and the transform is Rot(x,α_{i−1})·Trans(x,a_{i−1})·Rot(z,θᵢ)·Trans(z,dᵢ). Both give the same end-effector pose, but tables and matrices from the two cannot be mixed.

  4. 4.How do you place the x-axis when two consecutive joint axes are parallel or intersect?Concept

    If z_{i−1} and zᵢ are parallel, the common normal is not unique, so you choose one that makes dᵢ zero where possible, usually passing through the previous origin. If they intersect, aᵢ = 0 and xᵢ is taken along ±(z_{i−1} × zᵢ), perpendicular to both, with the origin at the intersection point.

  5. 5.Why can standard DH parameters be a problem in robot calibration?Concept

    When two consecutive joint axes are nominally parallel, a tiny real misalignment makes the common normal jump far along the axis, so dᵢ changes by a large amount for a small physical error. The parameter set is then ill-conditioned and the calibration fit becomes unstable. Calibration therefore often uses modified parameterisations, such as the Hayati extra rotation about y, for parallel axes.

  6. 6.Given a DH table, how do you get the end-effector pose?Concept

    Substitute each row into the link transform Aᵢ = Rot(z,θᵢ)·Trans(z,dᵢ)·Trans(x,aᵢ)·Rot(x,αᵢ) and multiply in order: ⁰Tₙ = A₁·A₂·…·Aₙ. The top-left 3×3 block is the tool orientation and the fourth column is the tool position in the base frame. A tool transform for the gripper length is appended at the end if the last frame is on the flange.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?