# Computing the Jacobian matrix for Inverse Kinematics

When computing the Jacobian matrix for solving an Inverse Kinematic analytically, I read from many places that I could use this formula to create each of the columns of a joint in the Jacobian matrix:

$$\mathbf{J}_{i}=\frac{\partial \mathbf{e}}{\partial \phi_{i}}=\left[\begin{array}{c}{\left[\mathbf{a}_{i}^{\prime} \times\left(\mathbf{e}_{p o s}-\mathbf{r}_{i}^{\prime}\right)\right]^{T}} \\ {\left[\mathbf{a}_{i}^{\prime}\right]^{T}}\end{array}\right]$$

Such that $$a'$$ is the rotation axis in world space, $$r'$$ is the pivot point in world space, and $$e_{pos}$$ is the position of the end effector in world space.

However, I don't understand how this can work when the joints have more than one DOFs. Take the following as an example: The $$\theta$$ are the rotational DOF, the $$e$$ is the end effector, the $$g$$ is the goal of the end effector, the $$P_1$$, $$P_2$$ and $$P_3$$ are the joints.

First, if I were to compute the Jacobian matrix based on the formula above for the diagram, I will get something like this:

$$J=\begin{bmatrix} ((0,0,1)\times \vec { e } )_{ x } & ((0,0,1)\times (\vec { e } -\vec { P_{ 1 } } ))_{ x } & ((0,0,1)\times (\vec { e } -\vec { P_{ 2 } } ))_{ x } \\ ((0,0,1)\times \vec { e } )_{ y } & ((0,0,1)\times (\vec { e } -\vec { P_{ 1 } } ))_{ y } & ((0,0,1)\times (\vec { e } -\vec { P_{ 2 } } ))_{ y } \\ ((0,0,1)\times \vec { e } )_{ z } & ((0,0,1)\times (\vec { e } -\vec { P_{ 1 } } ))_{ z } & ((0,0,1)\times (\vec { e } -\vec { P_{ 2 } } ))_{ z } \\ 0 & 0 & 0 \\ 0 & 0 & 0 \\ 1 & 1 & 1 \end{bmatrix}$$

This is assumed that all the rotation axes are $$(0,0,1)$$ and all of them only have one rotational DOF. So, I believe each column is for one DOF, in this case, the $$\theta_\#$$.

Now, here's the problem: What if all the joints have full 6 DOFs? Say now, for every joint, I have rotational DOFs in all axes, $$\theta_x$$, $$\theta_y$$ and $$\theta_z$$, and also translational DOFs in all axes, $$t_x$$, $$t_y$$ and $$t_z$$.

To make my question clearer, suppose if I were to "forcefully" apply the formula above to all the DOFs of all the joints, then I probably will get a Jacobian matrix like this: (click for full size)

But this is incredibly weird because all the 6 columns of the DOF for every joint is repeating the same thing.

How can I use the same formula to build the Jacobian matrix with all the DOFs? How would the Jacobian matrix look like in this case?

• Actually, I am not sure if I should have posted this question here, in Math, in GamesDev, or in Physics. I have a feeling that I have posted this question at the wrong place. Nov 26, 2012 at 10:44
• I think your mistake is that you didn't change the a' for each DOF, that's why they look all the same.
– user1138
Apr 8, 2013 at 11:05

I have to admit that i haven't seen that specific formula very often, but my guess would be that in case of more than one DOF, you would evaluate it for every joint in every column and then (perhaps?) multiply those results in each column.

But let me suggest a simpler apporach to Jacobians in the context of arbitrary many DOFs: Basically, the Jacobian tells you, how far each joint moves, if you move the end effector frame in some arbitrarily chosen direction. Let $f(\theta)$ be the forward kinematics, where $\theta = [\theta_1, ... , \theta_n]$ are the joints, $f_{\text{pos}}$ is the positional part of the forward kinematics and $f_{\text{rot}}$ the rotational part. Then you can obtain the Jacobian by differentiating the forward kinematics with respect to the joint variables: $$J = \frac{\partial f}{\partial \theta} = \begin{bmatrix} \frac{\partial f_{\text{pos}}}{\partial \theta_1}, & \frac{\partial f_{\text{pos}}}{\partial \theta_2} & ..., \frac{\partial f_{\text{pos}}}{\partial \theta_n} \\ \frac{\partial f_{\text{rot}}}{\partial \theta_1}, & \frac{\partial f_{\text{rot}}}{\partial \theta_2} & ..., \frac{\partial f_{\text{rot}}}{\partial \theta_n} \end{bmatrix}$$ is your manipulator's Jacobian. Inverting it would give you the inverse kinematics with respcet to velocities. It can still be useful though, if you want to know how far each joint has to move if you want to move your end effector by some small amount $\Delta x$ in any direction (because on position level, this would effectively be a linearization): $$\Delta \theta = J^{-1}\Delta x$$

Hope that this helps.

• Thanks for replying! But this would mean that I will have to compute the values numerically? Actually, I saw this analytical example from graphics.cs.cmu.edu/nsp/course/15-464/Fall09/handouts/IK.pdf from Slide 19 and graphics.ucsd.edu/courses/cse169_w05/CSE169_13.ppt on Slide 78. From the slides, it seem that I may not have to go through the numerical methods. In situations when I don't have the actual functions to differentiate, I can use this formula. But the problem is what happens when I have more DOFs for each joint. Nov 26, 2012 at 11:11
• If I understand the slides correctly, you would handle the case of arbitrary many (rotational) DOFs by determining the vectors $(e_i - P_i)$ for each of those joints, where $P_i$ is the joint's position. So, if you have, say 46 joints, you would indeed get a Jacobian with 46 columns and 6 rows (or 3, if you neglect the end effector's orientation). Long story short: you can apply that formula for any number of joints and don't have to "combine" it with other joints. Nov 26, 2012 at 11:36
• But what happens if a joint has many DOFs like $\theta_x$, $\theta_y$, $\theta_z$, and translational DOFs like $t_x$, $t_y$, $t_z$? Now, each joint has 6 DOFs. From my understanding of how the Jacobian matrix work for IK, the first 6 columns will be the derivatives of the end-effector with respect to the 6 different DOFs, and these first 6 columns are to describe the first joint. The subsequent next 6 columns will describe the second joint with respect to the 6 DOFs and so on. Using the equation $(e_i - P_i)$, does it mean each joint's 6 columns are automatically packed into one column? Nov 26, 2012 at 11:49
• Ah, I see. No, in that case, the formula wouldn't work because it was designed for rotational joints with one axis of rotation. If you want to treat e.g. spherical joints, you would either need a different formula which treats that specific joint type or you need a closed form of the robot's forward kinematics. If you have that, you can differentiate it w.r.t. the joints $\theta$ and obtain the Jacobian. Nov 26, 2012 at 12:22
• Thanks! :) Just curious though, is Slide 58 in graphics.ucsd.edu/courses/cse169_w05/CSE169_13.ppt hinting that it is possible to use the formula for rotational joints with 3 DOFs? Which means if a joint has no translational DOFs and have purely 3 rotational DOFs, it is still possible? Though I am not sure why it is taking $(1,0,0,0)$ to multiply with various rotations to get the different DOFs. Nov 26, 2012 at 12:55

Your formula for a 6 dof joint assumes that all 6 joints have the axis $(0, 0, 1)$ in the world frame and that all joints are revolute. Since the 6 joints are thus identical, their columns in the Jacobian are also identical.

Starting over, suppose a joint has an axis $a$ going through a point $r$. Let $e$ be the position of the end-effector. The coordinates of $a$, $r$, and $e$ are all given in the world frame and are being updated as the robot is being moved. The axis $a$ has length $1$.

If the joint is revolute, the column of the Jacobian for the joint is

$J_{\theta}(a, r) = \left[\begin{matrix} a \times (e - r) \\ a \end{matrix}\right]$

If the joint is prismatic, the column is

$J_{p}(a) = \left[\begin{matrix} a \\ 0 \end{matrix}\right]$

Suppose we have a 6 dof joint which is not only spherical but can translate in space too. Suppose the axes of the joint are $a_x$, $a_y$, and $a_z$ and that each revolute and prismatic joint shares an axis, so that the Jacobian for the joint becomes

$J = \left[\begin{matrix} J_p(a_x) & J_p(a_y) & J_p(a_z) & J_{\theta}(a_x, r) & J_{\theta}(a_y, r) & J_{\theta}(a_z, r) \end{matrix}\right]$

The axes $a_x$, $a_y$, and $a_z$ depend on the forward kinematics of the robot. To illustrate, let the transformation of the $k$th joint in the world frame be given by

$F_k = \prod_{i=1}^{k} L_i T_i$

where the transformations $L_i$ are constants, and the transformations $T_i$ depend on the joint variables. Let $R_c(q)$ and $P_c(q)$ be the transformations that rotate and translate by $q$ about the coordinate axis named $c$ (either $x$, $y$, or $z$).

Let $\Delta q = (\Delta p_x, \Delta p_y, \Delta p_z, \Delta \theta_x, \Delta \theta_y, \Delta \theta_z)$ be a displacement, computed by help of the Jacobian, for the $i$th joint. Let $\Delta T = P_x(\Delta p_x) P_y(\Delta p_y) P_z(\Delta p_z) R_x(\Delta \theta_x) R_y(\Delta \theta_y) R_z(\Delta \theta_z)$ and update the local transformation of the joint by:

$T_i \leftarrow T_i \, \Delta T$

In this formulation of the forward kinematics, the axes $a_x$, $a_y$, and $a_z$ of joint $i$ are exactly the columns of the rotation matrix of $F_i$. Also the position $r$ is the translation vector of $F_i$.

One way is to find the Jacobian using Perturbation method.

Basically, you compute forward kinematic matrix and find each entry through numeric differentiation

for each f(θ1+Δθ, θ2, θ3...) subtract f(θ1, θ2, θ3) divide by Δθ

θ1, θ2+Δθ, θ3... subtract f(θ1, θ2, θ3) divide by Δθ

and so on

As far as I understand your question that you want the Jacobian matrix for the 6 DOF joint.

Let me start with very basics of robotics. You are in the vary initial phase of robotics learning. You need to understand that each joint represent a single DOF either it would be revolute or prismatic joint.

As far as spherical joint is concern, it can be converted in to 3 revolute joint with three mutually perpendicular axis. So, now you have simplified your spherical joint.

Moving forward to Jacobian matrix. It contain 6 rows. First 3 rows represents orientation and last 3 rows indicated position with reference to a particular coordinate system. Each column in matrix indicate a single joint. So the number of joint/DOF you have the same number column you have in Jacobian matrix.

Here is the more clear view to your question: A single joint never fulfil more than one DOF, because it complicates the joint and precise control will never achieve. Even if we consider hypothetically a joint with more than one DOF, you need to convert that joint into multiple joints with 1 DOF each to simplify the mathematics and solution.

Ideally 6 DOF robot with 6 revolute joint works for majority on the real problems. But as per your question you considered 6 joint robot with each joint having 3 DOF that makes 18 DOF robot. This will give redundant DOF (i.e. 18-6= 12 redundant DOF). So, to reach robot end-effector to any location with any orientation you will have infinite different solutions (solution means rotation of each joint). So solve this kind of inverse kinematics problem you will require iterative method of inverse kinematics.

Hope, I have answered your question more clearly. To learn basic robotics you can refer John J. Craig - Introduction to Robotics Mechanics and Control -Pearson Education, Inc.

Regards, Manan Kalasariya