Computing the Jacobian Matrix -- chain rule?

I am learning about robot kinematics and the Jacobian matrix, and I'm trying to understand how to compute the Jacobian matrix given a kinematic chain, such as a robot arm. I understand the theory behind the Jacobian matrix, but I'm not sure actually how it would be calculated in practice.

So, let's say that I have a 7 DoF robot arm, with 7 joints and 6 links between the joints. I know how to compute the transformation matrix between each joint, and by applying forward kinematics, I know the pose of the end effector for any configuration of joint angles. To calculate this, I have written some code which stores each transformation matrix, and then multiplies them in series to create the transformation matrix between the first joint and the end effector.

However, how do I now go about computing the Jacobian matrix? My solution so far, is to write down each transformation matrix by hand, then multiply them all by hand, to yield the overall transformation matrix, with respect to the joint angles. I could then differentiate this to create the Jacobian matrix. The problem with this though, is that the maths becomes very, very complicated as I move along the kinematic chain. By the end, there are so many terms as a result of the multiple matrix multiplications, that it just becomes so tedious doing this by hand.

Is there a better way to do this? In the case of calculating the forward kinematics, I didn't have to do it by hand, I just wrote some code to multiply the individual matrices. But when I want the Jacobian matrix, it seems like I need to compute the derivative of the overall transformation matrix after it has been computed, and so I need to do this by hand. What's the standard solution to this? Is it something to do with the chain rule for differentiation...? I'm not sure exactly how this applies here though...

Thank you!

• see jacobian() in Matlab. It can determine the jacobian matrix with ease and comfort. May 20 '16 at 16:39

Writing the equations by hand and deriving them is certainly the best way to understand what is happening "in the background". Generating the equations and deriving them using a syombolics engine, like @SteveO suggested is essentially the same process but someone else, in this case a symbolic engine, is doing the work for you.

There are however different approaches to obtain the jacobi matrix, geometrically.

You can consider that the Jacobi matrix is built up from submatrices.

$$J = \left[ \begin{matrix} J_T \\ \hdashline J_\omega \end{matrix} \right] = \left[ \begin{matrix} J_{T_{1}}\quad J_{T_{2}} \quad \dots \quad J_{T_{n}}\\ \hdashline\hdashline J_{\omega_{1}} \quad J_{\omega_{2}} \quad \dots \quad J_{\omega_{n}}\\ \end{matrix} \right] = \left[ \begin{matrix} \frac{\delta x}{\delta q_1} \; \frac{\delta x}{\delta q_2} \; \dots \; \frac{\delta x}{\delta q_n} \\ \frac{\delta y}{\delta q_1} \; \frac{\delta y}{\delta q_2} \; \dots \; \frac{\delta y}{\delta q_n} \\ \frac{\delta z}{\delta q_1} \; \frac{\delta z}{\delta q_2} \; \dots \; \frac{\delta z}{\delta q_n} \\ \hdashline \frac{\delta \alpha}{\delta q_1} \; \frac{\delta \alpha}{\delta q_2} \; \dots \; \frac{\delta \alpha}{\delta q_n} \\ \frac{\delta \beta}{\delta q_1} \; \frac{\delta \beta}{\delta q_2} \; \dots \; \frac{\delta \beta}{\delta q_n} \\ \frac{\delta \gamma}{\delta q_1} \; \frac{\delta \gamma}{\delta q_2} \; \dots \; \frac{\delta \gamma}{\delta q_n} \\ \end{matrix} \right]$$

If your joint is a rotational joint than the its corresponding part in the Jacobi matrix is

$$\left[ \begin{matrix} J_{T_{i}} \\ \hdashline J_{\omega_{i}} \end{matrix} \right] = \left[ \begin{matrix} \overrightarrow b_{i-1} \times \overrightarrow r_{i-1,ee} \\ \hdashline \overrightarrow b_{i-1} \end{matrix} \right]$$

If your joint is a translational joint than the its corresponding part in the Jacobi matrix is $$\left[ \begin{matrix} J_{T_{i}} \\ \hdashline J_{\omega_{i}} \end{matrix} \right] = \left[ \begin{matrix} \overrightarrow b_{i-1} \\ \hdashline 0_{_{1 \times 3}} \end{matrix} \right]$$

where

• $\overrightarrow b_{i-1}$ is the vector of the joint axis
• $\overrightarrow r_{i-1,ee}$ is the vector pointing from the origin of the joint coordinate system to origin of the end-effector coordinate system
• $i$ refers to the Denavti Hartenber coordinate system numerotiation

You are right about the tedious nature of multiplying all those individual matrices by hand! You could search online for robot kinematics software and find some nice tools to help with this, but you learn it so much better when you actually work out the equations. Since you've already written the forward kinematics code, it's clear you understand that process. I recommend you use a symbolic algebra package (I used to use Maple IV, and that functionality is now within MatLab). Re-write the forward kinematics program, but do not plug in values for each joint angle. You'll end up with very long expressions for each term of $\vec x$, which can be reduced significantly by applying trigonometric identities. The identities for $\sin (\theta_2 + \theta_3)$ and $\cos (\theta_2 + \theta_3)$ are particularly helpful for articulated arm geometries.

Regarding the Jacobian, I have always found differentiating the forward kinematics to be rather straightforward. The chain rule isn't a major complicating factor, since each term is based on partial, not full, derivatives. A symbolic algebraic tool can be helpful here, too.

I think the key for your situation is to first determine the kinematics in closed-form (keeping the $\theta_i$ terms in the equations). Also compute the Jacobian in closed-form. Then you have the equations ready for plugging in joint values regardless of the robot's pose.

For a robot with a kinematic model expressed using standard DH parameters the classic reference is:

Differential Kinematic Control Equations for Simple Manipulators, Paul, Shimano, Mayer, IEEE SMC 11(6) 1981, pp. 456-460

This is implemented in many software tools include the Robotics Toolbox for MATLAB as the method jacobe which gives the Jacobian for velocity expressed in the end-effector coordinate frame. This method is used by jacob0 for velocity expressed in the world coordinate frame.

To compute the forward kinematics as suggested above you can use the fkine method with symbolic joint variables and the result can then be differentiated symbolically. MATLAB has pretty good symbolic support these days.

If you want to write the forward kinematics as a simple string of transformations (sidestepping the whole DH parameter thing) and do the chain rule then this article might be of interest.