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.
- 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:
- Number the joints from the base. Put the z axis of frame
i-1along the axis of jointi. - Place the x axis of each frame along the common perpendicular between consecutive z axes, pointing from the old frame to the new one.
- Complete the y axis with the right-hand rule.
- 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.
Table for a Two-Link Arm
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.
| Joint | theta | d (m) | a (m) | alpha |
|---|---|---|---|---|
| 1 | theta1 (variable) | 0 | 0.30 | 0 |
| 2 | theta2 (variable) | 0 | 0.20 | 0 |
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:
x = 0.30 * 0.8660 + 0.20 * 0.2588 = 0.2598 + 0.0518 = 0.3116y = 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:
x = 0.8660 * 0.1414 - 0.5000 * 0.1414 + 0.2598 = 0.1225 - 0.0707 + 0.2598 = 0.3116y = 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
- Fully straighten a drawn arm on paper with both angles at 0. The tool should be at
(a1 + a2, 0), here(0.50, 0). - Set
theta2 = 90degrees andtheta1 = 0. The tool should be at(a1, a2), here(0.30, 0.20). - Compute the base-to-tool distance two ways, from the coordinates and from the law of cosines, and compare.
- 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
thetain degrees into functions that expect radians. - Treating a prismatic joint like a revolute one: for a sliding joint,
dis the variable andthetais 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.
Related reading
- URDF tutorial for ROS 2: another way to describe links and joints, used by simulators.
- Arduino 3-DOF robot arm: a build where a DH table helps plan the maths.
- Servo motor with Arduino: how the joint angles reach the hardware.
- Time Constant and Step Response in a Motor Test
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.



