Denavit-Hartenberg Parameters: A Step-by-Step Example

Denavit-Hartenberg (DH) parameters describe each link of a robot arm with four numbers, which you place in a table and turn into one 4×4 matrix…

Reference
RE-4108
Published
Read
7 min

About the author · Editorial & verification standards

Studio illustration of a protected 18650 battery pack and charger

Denavit-Hartenberg (DH) parameters describe each link of a robot arm with four numbers, which you place in a table and turn into one 4×4 matrix per joint. Multiply those matrices in order and you get the position and orientation of the tool.

Key takeaways

  • Each joint gets four DH parameters: joint angle theta, link offset d, link length a and link twist alpha.
  • For a planar two-link arm, d and alpha are zero, so only theta and a remain.
  • The transform from one frame to the next is one fixed matrix pattern, filled with the row values.
  • The classic and modified DH conventions differ in frame placement, so never mix formulas from both.

What the Four Parameters Mean

The four DH parameters are the minimum numbers needed to move from the frame on one joint to the frame on the next. This article uses the classic convention, where link i sits between joint i and joint i+1.

6-AXIS ROBOT KINEMATICS & TOOL CENTER POINT (TCP) CHAINBase Frame {0}World Origin (X0,Y0,Z0)Joints J1–J3Waist · Shoulder · ElbowSpherical Wrist J4–J6Roll · Pitch · Yaw (R)TCP Frame {T}6-DOF Pose T06·TeForward Kinematics (FK)DH Matrix A1·A2·…·A6 → PoseInverse Kinematics (IK)Target Pose → Joint Angles q1..q6
Figure: 6-axis serial manipulator coordinate chain from Base {0} through J1–J6 to the Tool Center Point {TCP}.
  • theta is the joint angle: rotation about the z axis, from the old x axis to the new x axis. For a revolute joint this is the variable that moves.
  • d is the link offset: distance along the z axis between the two x axes. It is constant for a revolute joint.
  • a is the link length: distance along the new x axis between the two z axes.
  • alpha is the link twist: rotation about the new x axis, from the old z axis to the new z axis.

Think of it as two screw motions: one about z (theta and d), then one about x (a and alpha). The idea of chaining frames is introduced in the robot arm kinematics basics post.

Assigning Frames

Assigning frames means attaching a coordinate system to each link by a fixed set of rules, so that the four parameters above can be read off. The usual rules for the classic convention are:

  1. Number the joints from the base. Put the z axis of frame i-1 along the axis of joint i.
  2. Place the x axis of each frame along the common perpendicular between consecutive z axes, pointing from the old frame to the new one.
  3. Complete the y axis with the right-hand rule.
  4. Put the base frame at the first joint, and the tool frame at the end of the last link.

For a planar arm all joint axes point out of the page, so every z axis is parallel. That makes alpha = 0 and d = 0 everywhere, and the x axes simply run along the links.

A DH table has one row per joint. Assumptions for this example: link 1 is 0.30 m long and link 2 is 0.20 m long, both revolute joints, both in the same plane.

Jointthetad (m)a (m)alpha
1theta1 (variable)00.300
2theta2 (variable)00.200

Only theta1 and theta2 change while the arm moves. If you are building a similar arm, the two-link arm inverse kinematics project uses the same geometry in reverse, working out the angles needed to reach a point.

Building the Transform Matrix

The DH transform matrix is the single formula that converts one table row into a 4×4 matrix. In the classic convention:

A_i = | cos(th)  -sin(th)*cos(al)   sin(th)*sin(al)   a*cos(th) |
      | sin(th)   cos(th)*cos(al)  -cos(th)*sin(al)   a*sin(th) |
      |   0           sin(al)           cos(al)           d      |
      |   0              0                 0              1      |

With alpha = 0 and d = 0, it simplifies to:

A_i = | cos(th)  -sin(th)  0  a*cos(th) |
      | sin(th)   cos(th)  0  a*sin(th) |
      |   0          0     1      0     |
      |   0          0     0      1     |

The tool pose is T = A_1 * A_2. Multiplying the two matrices and reading the position column gives the familiar planar result:

x = a1*cos(th1) + a2*cos(th1 + th2)
y = a1*sin(th1) + a2*sin(th1 + th2)

The sum th1 + th2 appears because the second link’s heading is the sum of both joint angles in a planar arm. Matrix products like this one are the same 4×4 homogeneous transforms used for camera and robot frames in ROS.

Checking the End Position

Checking the end position means computing the tool position two ways and confirming they agree. Take theta1 = 30 degrees and theta2 = 45 degrees, so th1 + th2 = 75 degrees. Use cos 30 = 0.8660, sin 30 = 0.5000, cos 75 = 0.2588, sin 75 = 0.9659.

Method 1, direct formula:

  1. x = 0.30 * 0.8660 + 0.20 * 0.2588 = 0.2598 + 0.0518 = 0.3116
  2. y = 0.30 * 0.5000 + 0.20 * 0.9659 = 0.1500 + 0.1932 = 0.3432

Method 2, step by step with matrices. The tool origin in frame 1 is (a2*cos(th2), a2*sin(th2)) = (0.20 * 0.7071, 0.20 * 0.7071) = (0.1414, 0.1414). Rotate by theta1 and add the first link:

  1. x = 0.8660 * 0.1414 - 0.5000 * 0.1414 + 0.2598 = 0.1225 - 0.0707 + 0.2598 = 0.3116
  2. y = 0.5000 * 0.1414 + 0.8660 * 0.1414 + 0.1500 = 0.0707 + 0.1225 + 0.1500 = 0.3432

Both give (0.3116, 0.3432) metres. A third check uses the law of cosines. The distance from base to tool should be sqrt(a1^2 + a2^2 + 2*a1*a2*cos(th2)) = sqrt(0.09 + 0.04 + 0.0849) = sqrt(0.2149) = 0.4635 m. And sqrt(0.3116^2 + 0.3432^2) = sqrt(0.0971 + 0.1178) = sqrt(0.2149) = 0.4635 m. The three checks agree. You can drag a virtual arm and compare the numbers in the robot arm playground.

Errors in Frame Choice

A frame choice error is any mistake in placing axes that makes the table values wrong even though the matrix maths is right. The usual causes are below. For going the other way, from a target to joint angles, see the inverse kinematics in Python post, and the Learn hub for related topics.

  • Choosing a z axis that is not along the joint axis.
  • Pointing x the wrong way along the common perpendicular, which flips the sign of a link length.
  • Mixing classic and modified DH formulas. Modified DH places frames differently and uses a different matrix.
  • Forgetting a joint-zero offset: if your arm’s “zero” pose is not straight, add a constant to theta.

How to check this yourself

  1. Fully straighten a drawn arm on paper with both angles at 0. The tool should be at (a1 + a2, 0), here (0.50, 0).
  2. Set theta2 = 90 degrees and theta1 = 0. The tool should be at (a1, a2), here (0.30, 0.20).
  3. Compute the base-to-tool distance two ways, from the coordinates and from the law of cosines, and compare.
  4. Draw the arm to scale with a protractor at your chosen angles and measure the tool position with a ruler. It should match your formula within drawing error.

Common mistakes

  • Copying a DH table from a paper that uses the modified convention into classic formulas.
  • Putting theta in degrees into functions that expect radians.
  • Treating a prismatic joint like a revolute one: for a sliding joint, d is the variable and theta is fixed.
  • Ignoring the mechanical zero of the servo, so the code’s zero angle does not match the physical arm.

Quick checklist

  • Decide classic or modified DH and stay with it.
  • Put each z axis along its joint axis.
  • Fill the table, one row per joint.
  • Multiply the matrices in base-to-tool order.
  • Check the end position with a second method.

Frequently asked questions

What are Denavit-Hartenberg parameters?

They are four numbers per joint, theta, d, a and alpha, that describe how one link frame sits relative to the previous one. Put them in a table, convert each row into a 4×4 matrix, and multiply the matrices to get the pose of the tool.

Do I need DH parameters for a hobby servo arm?

Not strictly. For a planar two or three link arm, the angle-sum formulas are enough and simpler. DH becomes valuable for arms with joints in several planes, or when you want a standard table that other robotics software can use. It is a common topic in robotics coursework for exactly that reason.

What is the difference between classic and modified DH?

Both use the same four parameters but attach frames at different ends of each link, so the matrix formula differs in the order of the screw motions. Results for the final pose are equivalent when done correctly, but the table values are not interchangeable, so use one convention consistently.

About the author and how this is kept accurate

Written, checked and maintained by Jignesh Panchal of Jaadu Digital. Figures in worked examples come from the stated assumptions, not from a bench test of our own. Read the editorial standard, follow the author on LinkedIn, or send a correction. Last reviewed: November 2026.

Pass it onWhatsAppLinkedIn

Keep reading

Continue learning

Free: the final-year project pack

A shortlist with BOMs, a report outline that matches the usual chapter scheme, a costing sheet and 40 viva questions. Built for the February–April submission season.

The Build Note

One short email when something is worth your bench time.

A new build sheet, a part price that moved, or a mistake worth avoiding. No daily drip, no recycled news.

One short email when a build or a price is worth your time. Unsubscribe in one click.