Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 38 · Kinematics

Forward Kinematics

Compute where a robot arm's end effector is from its joint angles: planar two-link and three-link arms, Denavit-Hartenberg parameters and a 3D arm in NumPy.

Forward kinematics (FK) answers one question: given the joint values of a robot, where is its end effector? You know the angles that the encoders report; you want the position and orientation of the gripper in the world. The answer comes from the frame chaining of the previous lesson: place a frame on every link and multiply the transforms from the base outward.

FK is always possible and has exactly one answer. Its opposite, inverse kinematics, is harder. FK is also the building block for drawing the robot, checking collisions and computing velocities with the Jacobian.

Take two links of lengths l1 and l2 in a plane. The shoulder angle θ1 is measured from the x axis; the elbow angle θ2 is measured relative to the first link. Then:

Text
x = l1 cos(θ1) + l2 cos(θ1 + θ2)
y = l1 sin(θ1) + l2 sin(θ1 + θ2)
φ = θ1 + θ2            (orientation of the last link)

The elbow position is (l1 cos θ1, l1 sin θ1); the second link just adds another vector pointing in direction θ1 + θ2. Angles accumulate because the elbow's angle is relative.

Python Two-link arm: draw it for several poses

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The general method: one transform per joint

Rather than deriving trigonometry for each robot, build a transform for each link and multiply. In 2D each link is "rotate by the joint angle, then move along the link":

T_i = Rot(θ_i) @ Trans(l_i, 0)

and the tip pose is T = T_1 @ T_2 @ ... @ T_n. This works for any number of joints, and it is the pattern that scales to 3D.

Python A generic planar chain with N joints

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Denavit-Hartenberg parameters

In 3D, choosing a frame on each link freely leads to messy, inconsistent models. The Denavit-Hartenberg (DH) convention fixes the frame placement rules so that each joint is described by just four numbers:

Parameter Meaning
a link length: distance between joint axes along the common normal (x axis)
α link twist: angle between the joint axes about x
d link offset: distance along z between consecutive x axes
θ joint angle: rotation about z between consecutive x axes

For a revolute joint, θ is the variable; for a prismatic joint, d is the variable. The transform from frame i-1 to frame i is

T = Rz(θ) · Tz(d) · Tx(a) · Rx(α)

and the pose of the end effector is the product of all of them. Many textbooks and datasheets list a robot as a table of DH rows, so reading and implementing that table is a core skill. (A "modified" DH convention puts a and α before θ and d; always check which one a table uses.)

Python DH forward kinematics for a 3-joint arm

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

With all joints at zero the arm lies straight out along x: reach 0.9 and height 0.3. When the waist turns 90 degrees the tip swings to the y axis. Checking such obvious poses is the best test of a DH table.

Tips and checks

  • Test simple poses (all zeros, 90 degrees) where you can predict the answer by hand.
  • Check that the rotation part of the result still has determinant 1; if not, the code has a bug.
  • Keep link lengths in one unit (meters) and angles in radians.
  • Draw the robot. A plot reveals a wrong sign far faster than numbers do.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What does forward kinematics compute?

    FK maps joint space to task space: joint values in, tool pose out.
  2. 2. For a planar two-link arm, what is the tip's x coordinate?

    The elbow angle is relative to the first link, so the second link points in direction θ1 + θ2.
  3. 3. Which are the four Denavit-Hartenberg parameters?

    Link length a, twist alpha, offset d and joint angle theta.
  4. 4. How many solutions does forward kinematics give for a given set of joint values?

    FK is a function: one set of joints gives one pose. Inverse kinematics can have several or no solutions.

Summary

  • Forward kinematics multiplies one transform per link to get the end-effector pose.
  • For planar arms the formula is a sum of link vectors with cumulative angles.
  • DH parameters describe each joint with four numbers; the table is a compact robot model.
  • Always sanity-check FK on poses you can predict and by plotting.

Next: Inverse Kinematics