Kinematics of a Robotic Manipulator

Robotic manipulators are widely used in industry. They are simpler than mobile robots in that they perform tasks in a fixed and known environment. They are more complex than mobile robots because they move in the three spatial dimensions and in the three dimensions of rotation. Using a simplified planar model of a robotic arm, the two central problems of manipulators are presented. Forward kinematics asks where the end effector of the arm will be following a sequence of rotations of the joints of the arm. Inverse kinematics asks what rotations of the joints will bring the end effector to a specified position. A rotation of a robotic manipulator is described by a rotation matrix whose elements are trigonometric functions of the angle of rotation. The rotation matrix for a planar rotation is derived followed by an overview of three-dimensional rotations.

you start with one desired position and have to look for a sequence of commands to reach that position. A problem in inverse kinematics may have one solution, multiple solutions or even no solution at all.
Kinematic computations are performed in terms of coordinate frames. A frame is attached to each joint of the manipulator and motion is described as transformations from one frame to another by rotations and translations. Transformation of coordinate frames in two-dimensions is presented in Sects. 16. 3 and 16.4. Most robots manipulators are three-dimensional. The mathematical treatment of 3D motion is beyond the scope of this book, but we hope to entice you to study this subject by presenting a taste of 3D rotations in Sects. 16.5 and 16.6.

Forward Kinematics
We develop the kinematics of a two-dimensional robotic arm with two links, two joints and an end effector such as a gripper, a welder or a paint sprayer ( Fig. 16.1). The first joint can rotate but it is mounted on a base that is fixed to a table or the floor. Link l 1 connects this joint to a second joint that can move and rotate; a second link l 2 connects this joint to the fixed end effector.
A two-dimensional coordinate system is assigned with the first joint at (0, 0). The lengths of the two links are l 1 and l 2 . Rotate the first joint by α to move the end of the first link with the second joint to (x , y ). Now rotate the second joint by β. What are the coordinates (x, y) of the end of the arm, in terms of the two constants l 1 , l 2 and the two parameters α, β?
Project (x , y ) on the x-and y-axes; by trigonometry its coordinates are: x = l 1 cos α y = l 1 sin α .
Now take (x , y ) as the origin of a new coordinate system and project (x, y) on its axes to obtain (x , y ). The position of the end effector relative to the new coordinate system is: x = l 2 cos(α + β) y = l 2 sin(α + β) .
In Fig. 16.1, β is negative (a clockwise rotation) so α + β is the angle between the second link and the line parallel to the x-axis.

Inverse Kinematics
The gray ring in Fig. 16.3 shows the workspace of the two-link arm, the set of positions that the end effector can reach. (We assume that l 2 < l 1 .) The workspace is circularly symmetric since we assume that there are no limitations of the rotation of the joints in a full circle between −180 • and 180 • . Any point like a on the circumference of the outer circle is a furthest position of the arm from the origin; it is obtained when the two links are lined up so the arm length is l 1 + l 2 . The closest positions to the origin in the workspace are points like b on the circumference of the inner circle; they are obtained when the second link is bend back on the first link giving a length of l 1 − l 2 . Another reachable position c is shown; there are two configurations (rotations of the joints) that cause the arm to be positioned at c. Under the assumption that l 2 < l 1 , no sequence of rotations can position the end of the arm closer to the origin that l 1 − l 2 and no position at a distance greater than l 1 + l 2 from the origin is accessible. From the figure we learn that a problem in inverse kinematics-finding commands to reach a specified point-can have zero, one or many solutions.
The computation of the inverse kinematics uses the lassw of cosines ( Fig. 16.4): In a right triangle cos 90 • = 0 and the law reduces to the Pythagorean theorem. Suppose now that we are given a point (x, y) and we want values for α, β (if any exist) which will bring the arm to that point.  By the Pythagorean theorem, r = x 2 + y 2 .
The law of cosines gives: which can be solved for β: To obtain γ and then α, use the law of cosines with γ as the central angle: From the right triangle formed by (x, y) we have: Example Assume again that l 1 = l 2 = 1 and that the end effector is at the point computed from the forward kinematics: First, compute r 2 : and use it in the computation of β: There are two solutions because there are two ways of moving the arm to (x, y). Next compute γ : (16.1) The inverse cosine can be obtained numerically on a calculator or algebraically as shown in Appendix B.7.
In this simple case, it is possible to solve the forward kinematics equation to obtain formulas for the inverse kinematics. In general this is not possible so approximate numerical solutions are used.

Activity 16.2: Inverse kinematics
• Use the formulas for the inverse kinematics to program your robot to move to a specified coordinate. • Measure the x-and y-distances of the robot from the origin and compare them to the specified coordinates. • If your robot's computer does not have the capability to compute the formulas, compute them offline and then input the commands to the robot.

Rotations
The motion of a robotic manipulator is described in terms of coordinate frames. Three frames are associated with the arm in Fig. 16.1: one frame is associated with the joint at the origin (which we assume is fixed to a table or the floor), a second frame is associated with the joint between the two links, and a third frame is associated with the end effector at the end of the second link.
In this section we describe how the rotational motion of a robotic arm can be mathematically modeled using rotation matrices. The links in robotic arms introduce translations: the second joint is offset by a linear distance of l 1 from the first joint, and the end effector is offset by a linear distance of l 2 from the second joint. The mathematical treatment of translations uses an extension of rotation matrices called homogeneous transforms.
Rotations can be confusing because a rotation matrix can have three interpretations that are described in the following subsections: rotating a vector, rotating a coordinate frame and transforming a vector from one coordinate frame to another.

Rotating a Vector
Consider a vector with cartesian coordinates (x, y) and polar coordinates (r, φ) ( Fig. 16.6a). Now rotate the vector by an angle θ ( Fig. 16.6b). Its polar coordinates are (r, φ + θ). What are its cartesian coordinates?
Using the trigonometric identities for the sum of two angles and the conversion of (r, φ) to (x, y) we have: These equations can be expressed as the multiplication of a matrix called the rotation matrix and a vector: Example Let p be the point at the tip of a vector of length r = 1 that forms an angle of φ = 30 • with the positive x-axis. The cartesian coordinates of p are √ 3 2 , 1 2 . Suppose that the vector is rotated by θ = 30 • . What are the new cartesian coordinates of p? Using matrix multiplication: The result makes sense because rotating a vector whose angle with the x-axis is 30 • by 30 • should give a vector whose angle with the x-axis is 60 • . Suppose that the vector is rotated by an additional 30 • ; its new coordinates are: This result also makes sense. Rotating a vector whose angle is 30 • twice by 30 • (for a total of 60 • ) should give 90 • . The cosine of 90 • is 0 and the sine of 90 • is 1.
Since matrix multiplication is associative, the multiplication could also be performed as follows:

Activity 16.3: Rotation matrices
• Demonstrate the associativity of matrix multiplication by showing that the multiplication in Eq. 16.3 gives the same result as the multiplication in Eq. 16.2. • Compute the matrix for a rotation of −30 • and show that multiplying this matrix by the matrix for a rotation of 30 • gives the matrix for a rotation of 0 • . • Is this multiplication commutative?
• Is multiplication of two-dimensional rotational matrices commutative?

Rotating a Coordinate Frame
Let us reinterpret Fig. 16.6a, b. Figure 16.7a shows a coordinate frame (blue) defined by two orthogonal unit vectors: Figure 16.7b shows the coordinate frame rotated by θ degrees (red). The new unit vectors x and y can be obtained by multiplication by the rotation matrix derived above:

Transforming a Vector from One Coordinate Frame to Another
Let the origin of a coordinate frame b (blue) represent the joint of an end effector such as a welder and let point p be the tip of the welder (Fig. 16.8a). By convention in robotics, the coordinate frame of an entity is denoted by a "pre" superscript. 1 In the frame b, the point b p has polar coordinates (r, φ) and cartesian coordinates ( b x, b y) related by the usual trigonometric formulas: Suppose that the joint (with its coordinate frame) is rotated by the angle θ . The coordinates of the point relative to b remain the same, but the coordinate frame has moved so we ask: What are the coordinates a p = ( a x, a y) of the point in the coordinate frame before it was moved? In In the previous section we asked how to transform one coordinate frame into another; here, we are asking how to transform the coordinates of a point in a frame to its coordinates in another frame.
In terms of the robotic arm: we know ( b x, b y), the coordinates of the tip of the end effector relative to the frame of the end effector, and we now ask for its coordinates a p = ( a x, a y) relative to the fixed base. This is important because if we know a p, we can compute the distance and angle from the tip of the welder to the parts of the car it must now weld.
We can repeat the computation used for rotating a vector: If frame a is now rotated 30 • , we obtain the coordinates of the point in a third frame a1. Pre-multiply a p by the rotation matrix for 30 • to obtain a1 p: The product of the two rotation matrices: results in the rotation matrix for rotating the original coordinate frame b by 60 • : Given a sequence of rotations, pre-multiplying their rotation matrices gives the rotation matrix for the rotation equivalent to the sum of the individual rotations.

Rotating and Translating a Coordinate Frame
The joints on robotics manipulators are connected by links so the coordinate systems are related not just by rotations but also by translations. The point p in Fig. 16.9 represents a point in the (red) coordinate frame b, but relative to the (blue dashed) coordinate frame a, frame b is both rotated by the angle θ and its origin is translated To perform this computation, we define an intermediate (green) coordinate frame a1 that has the same origin as b and the same orientation as a (Fig. 16.10). What are the coordinates a1 p = ( a1 x, a1 y) of the point in frame a1? This is simply the rotation by θ that we have done before: Homogeneous transforms are used to combine a rotation and a translation in one operator. The two-dimensional vector giving the coordinates of a point is extended with a third element that has a fixed value of 1: The rotation matrix is extended to a 3 × 3 matrix with a 1 in the lower right corner and zeros elsewhere. It is easy to check that multiplication of a vector in frame b by the rotation matrix results in the same vector as before except for the extra 1 element: The result is the coordinates of the point in the intermediate frame a1. To obtain the coordinates in frame a, we multiply by a matrix that performs the translation: By multiplying the two transforms, we obtain a single homogeneous transform that can perform both the rotation and that translation: Example Let us extend the previous example by adding a translation of (3, 1) to the rotation of 30 • . The homogeneous transform of the rotation followed by the translation is: ⎡ The coordinates of the point in frame a are:

Activity 16.4: Homogeneous transforms
• Draw the diagram for a rotation of −30 • followed by a translation of (3, −1).
• Compute the homogeneous transform.

A Taste of Three-Dimensional Rotations
The concepts of coordinate transformations and kinematics in three-dimensions are the same as in two dimensions, however, the mathematics is more complicated. Furthermore, many of us find it difficult to visualize three-dimensional motion when all we are shown are two-dimensional representations of three-dimensional objects.
In this section we give a taste of three-dimensional robotics by looking at rotations in three dimensions.

Rotations Around the Three Axes
A two-dimensional x-y coordinate frame can be considered to be embedded in a three-dimensional coordinate frame by adding a z-axis perpendicular to the x-and yaxes. Figure 16.11 shows a two-dimensional representation of the three-dimensional frame. The x-axis is drawn left and right on the paper and the y-axis is drawn up and down. The diagonal line represents the z-axis which is perpendicular to the other two axes. The "standard" x-y-z coordinate frame has the positive directions of its axes defined by the right-hand rule (see below). The positive directions are right for the x-axis, up for the y-axis and out (of the paper towards the observer) for the z-axis. Rotate the coordinate frame counterclockwise around the z-axis, so that the z-axis remains unchanged (Fig. 16.12a, b). The new orientation of the frame is (up, left, out). Consider now a rotation of 90 • around the x-axis (Fig. 16.13a, b). This causes the y-axis to "jump out" of the paper and the z-axis to "fall down" onto the paper, resulting in the orientation (right, out, down). Finally, consider a rotation of 90 • around the y-axis (Fig. 16.14a, b). The x-axis "drops into" the paper and the z-axis "falls right" onto the paper. The new position of the frame is (in, up, right).

The Right-Hand Rule
There are two orientations for each axis, 2 3 = 8 orientations overall. What matters is the relative orientation of one axis with respect to the other two; for example, once the x-and y-axes have been chosen to lie in the plane of the paper, the z-axis can have its positive direction pointing out of the paper or into the paper. The choice must be consistent. The convention in physics and mechanics is the right-hand rule. Curl the fingers of your right hand so that they go from the one axis to another axis. Your thumb now points in the positive direction of the third axis. For the familiar x-and y-axes on paper, curl your fingers on the path from the x-axis to the y-axis. When you do so your thumb points out of the paper and this is taken as the positive direction of the z-axis. Figure 16.15 shows the right-hand coordinate system displayed with each of the three axes pointing out of the paper. According to the right-hand rule the three rotations are: Rotate from x to y around z, Rotate from y to z around x, Rotate from z to x around y.

Matrices for Three-Dimensional Rotations
A three-dimensional rotation matrix is a 3 × 3 matrix because each point p in a frame has three coordinates p x , p y , p z that must be moved. Start with a rotation of ψ around the z-axis, followed by a rotation of θ around the y axis and finally a rotation of φ around the x-axis. For the first rotation around the z-axis, the x and y coordinates are rotated as in two dimensions and the z coordinate remains unchanged. Therefore, the matrix is: For the rotation by θ around the y-axis, the y coordinate is unchanged and the z and x coordinates are transformed "as if" they were the x and y coordinates of a rotation around the z-axis: For the rotation by φ around the x-axis, the x coordinate is unchanged and the y and z coordinates are transformed "as if" they were the x and y coordinates of a rotation around the z-axis: It may seem strange that in the matrix for the rotation around the y-axis the signs of the sine function have changed. To convince yourself that matrix for this rotation is correct, redraw the diagram in Fig. 16.8b, substituting z for x and x for y and perform the trigonometric computation.

Multiple Rotations
There is a caveat to composing rotations: like matrix multiplication, three-dimensional rotations do not commute. Let us demonstrate this by a simple sequence of two rotations. Consider a rotation of 90 • around the z-axis, followed by a rotation of 90 • around the (new position of the) x-axis ( Fig. 16.16). The result can be expressed as (up, out, right). Now consider the commuted operation: a rotation of 90 • around the x-axis, followed by a rotation of 90 • around the z-axis (Fig. 16.17). The result can be expressed as (out, left, down), which is not the same as the previous orientation.

Euler Angles
An arbitrary rotation can be obtained by three individual rotations around the three axes, so the matrix for an arbitrary rotation can be obtained by multiplying the matrices for each single rotation. The angles of the rotations are called Euler angles. The formulas are somewhat complex and can be found in the references listed at the end of the chapter. Here we demonstrate Euler angles with an example.
Example Figure 16.18 shows a coordinate frame rotated sequentially 90 • around the z-axis, then the y-axis and finally the x-axis. This is called a zyx Euler angle rotation. The final orientation is (in, up, right). Let us consider a robotic manipulator that consists of a single joint that can rotate around all three axes. A sequence of rotations is performed as shown in Fig. 16.18. Consider the point at coordinates (1, 1, 1) relative to the joint (Fig. 16.19a). After the rotations, what are the coordinates of this point in the original fixed frame?
This can be computed by leaving the vector fixed and considering the rotations of the coordinate frames. To reach the final position shown in Fig. 16.19a the frame was rotated around the x-axis from the orientation shown in Fig. 16.19b. By examining the figure we see that the coordinates in this frame are (1, −1, 1). Proceeding through the previous two frames (Fig. 16.20a, b), the coordinates are (1, −1, −1) and (1, 1, −1).
These coordinates can be computed from the rotation matrices for the rotations around the three axes. The coordinates of the final coordinate frame are (1, 1, 1), so in the frame before the rotation around the x-axis the coordinates were: ⎡ The coordinates in the frame before the rotation around the y-axis were: Finally, the coordinates in the fixed frame before the rotation around the z-axis were: For three arbitrary zyx Euler angle rotations: ψ around the z-axis, then θ around the y-axis and finally φ around the x-axis the rotation matrix is: It may seem strange that the order of the matrix multiplication (which is always from right to left) is opposite the order of the rotations. This is because we are taking a vector in the final coordinate frame and transforming it back into the fixed frame to determine its coordinates in the fixed frame.

Activity 16.5: Multiple Euler angles
• Multiply the three matrices to obtain a single matrix that directly transforms the coordinates from (1, 1, 1) to (1, 1, −1). • Perform the same computation for other rotations, changing the sequence of the axes and the angles of rotation.

The Number of Distinct Euler Angle Rotations
There are three axes so there should be 3 3 = 27 sequences of Euler angles. However, there is no point in rotating around the same axis twice in succession because the same result can be obtained by rotating once by the sum of the angles, so there are only 3 · 2 · 2 = 12 different Euler angles sequences. The following activity asks you to explore different Euler angle sequences.

Activity 16.6: Distinct Euler angles
• To experiment with three-dimensional rotations, it is helpful to construct a coordinate frame from three mutually perpendicular pencils or straws.

Advanced Topics in Three-Dimensional Transforms
Now that you have tasted three-dimensional rotations, we survey the next steps in learning this topic which you can study in the textbooks listed in the references.
There are 12 Euler angles and the choice of which to use depends on the intended application. Furthermore, there is a different way of defining rotations. Euler angles are moving axes transforms, that is, each rotation is around the new position of the axis after the previous rotation. In Fig. 16.18, the second rotation is around the y-axis that now points left, not around the original y-axis that points up. It is also possible to define fixed axes rotations in which subsequent rotations are around the original axes of the coordinate system. In three dimensions, homogeneous transforms that include translations in addition to rotations can be efficiently represented as 4 × 4 matrices.
Euler angles are relatively inefficient to compute and suffer from computational instabilities. These can be overcome by using quaternions, which are a generalization of complex numbers. Quaternions use three "imaginary" numbers i, j, k, where: Recall that a vector in the two-dimensional plane can be expressed as a complex number x + i y. Rotating the vector by an angle θ can be performed by multiplying by the value cos θ + i sin θ . Similarly, in three dimensions, a vector can be expressed as a pure quaternion with a zero real component: p = 0 + x i + y j + z k. Given an axis and an angle, there exists a quaternion q that rotates the vector around the axis by this angle using the formula qpq −1 . This computation is more efficient and robust than the equivalent computation with Euler angles and is used in a variety of contexts such as aircraft control and computer graphics.

Summary
Kinematics is the description of the motion of a robot. In forward kinematics, we are given a set of commands for the robot and we need to compute its final position relative to its initial position. In inverse kinematics, we are given a desired final position and need to compute the commands that will bring the robot to that position. This chapter has demonstrated kinematic computations for a simple two-dimensional robotic manipulator arm. In practice, manipulators move in three-dimensions and the computations are more difficult. Exact solutions for computing inverse kinematics usually cannot be found and approximate numerical solutions are used.
There are many ways of defining and computing arbitrary rotations. We mentioned the Euler angles where an arbitrary rotation is obtained by a sequence of three rotations around the coordinate axes. Quaternions, a generalization of complex numbers, are often used in practice because they are computationally more efficient and robust.

Further Reading
Advanced textbooks on robotic kinematics and related topics are those by Craig [2] and Spong et al. [3]. See also Chap. 3 of Correll [1]. Appendix B of [2] contains the rotation matrices for all the Euler angle sequences. The video lectures by Angela Sodemann are very helpful: https://www.youtube.com/user/asodemann3, http://www.robogrok.com/Flowchart.html.
Although not a book on robotics, Vince's monograph on quaternions [4] gives an excellent presentation of the mathematics of rotations.
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.