# pseudoinverse Jacobian and adding more control in computer animation

I am studying inverse kinematics. But I wonder the suggested equations. (The following equations are taken from 'Computer Animation Algorithms and Techniques Third Edition Page, 181')

To better control the kinematic model such as encouraging joint angle constraints, a control expression can be added to the pesudoinverse Jacobian solution.

($J$ is Jacobian, $J^+ = J^T(JJ^T)^{-1} = (J^TJ)^{-1}J^T$, and I will explain $z$ later)

The form for the control expression is the below eqution 5.25

$\theta = (J^+J - I)z\cdot\cdot\cdot\cdot(5.25)$

But, the $\theta$ is always zero vector because $J^+J = I$, so $\theta = \mathbf 0z$.

The book said that a change to pose parameters in the form of Equation 5.25 does not add anything to the velocities, so the control expression can be added to the pseudoinverse Jacobian solution without chaining the given velocities to be satisfied.

$V = J\theta \\ V = J(J^+J - I)z \\ V = \mathbf0z \\ V = \mathbf0 \cdot\cdot\cdot\cdot(5.26)$

And the book defined $z$ (Equation (5.27)) to bias the solution toward specific joint angles.

$z = \alpha_i(\theta_i - \theta_{ci})^2\cdot\cdot\cdot\cdot(5.27)$ where $\theta_i$ is the current joint angles, $\theta_{ci}$ are the desired joint angles, and $\alpha_i$ is joint gains.

Finally, The form of the conventional pseudoinverse of the Jocobian added by the contorol expression is Equation 5.28.

$\theta = J^+V + (J^+J - I)z \cdot\cdot\cdot\cdot(5.28)\\ \theta = J^+(V + Jz) -z \\ \theta = J^T[(JJ^T)^{-1}(V+Jz)] -z$

However, I could not understand why the book derived the above equation. Because the equation 5.25 is zero vector, the equation 5.28 of red part($\theta = J^+V + \color{red}{(J^+J - I)z}$) is zero vector and $z$ doesn't have any effect on the result. We just have $\theta = J^+V$, no difference from the real original conventional pseudoinverse.

What is wrong with me?

I think I found your misunderstanding, but it's IMHO based on a little inconsistency (or at least lack of clarity) in the book.

But, the θ is always zero vector because J+J=I, so θ=0z.

This is not true, $J^+J$ is not necessarily $I$. $JJ^+=I$ but the multiplication by the pseudoinverse is not commutative. Let's look at this in more detail:

$JJ^+ = JJ^T(JJ^T)^{-1}= (JJ^T)(JJ^T)^{-1} = I$

$J^+J = J^T(JJ^T)^{-1}J = ?$

The underlying misunderstanding comes from the assumption that the matrices $J^T(JJ^T)^{-1}$ and $(J^TJ)^{-1}J^T$ are equal (since the latter would produce $I$ if right-multiplied by $J$), which is not true. They are both pseudoinverses of $J$ but they are not necessarily the same matrices, in fact they don't necessarily both exist.

As the book says, the $(JJ^T)^{-1}$ only exists if the rows of $J$ are linearly independent, and in turn Wikipedia says that $(J^TJ)^{-1}$ exists if the columns of $J$ are linearly independent. However, they can't both exist if the matrix is not square, since one of the dimensions would necessarily have more vectors than the dimension, which can't all be linearly independent. Specifically, for a normal redundant joint system you probably have more columns than rows, making only the pseudoinverse $J(JJ^T)^{-1}$ exist.

We can, however, see that for a square matrix they are indeed the same and actually the real inverse:

$J^T(JJ^T)^{-1} = J^TJ^{-T}J^{-1} = (J^{-1}J)^TJ^{-1} = I^TJ^{-1} = J^{-1}$

$(J^TJ)^{-1}J^T = J^{-1}J^{-T}J^T = J^{-1}(JJ^{-1})^T = J^{-1}I^T = J^{-1}$

(But in that case the system would have a unique solution and there's no point to angle control anyway.) But you cannot resolve the brackets with a non-square matrix, since the individual matrices aren't square and don't have an actual inverse. The only situation when both matrices exist are square $J$s and then they are indeed equal, but then there's also no point to angle control.

But I understand why you are confused and I am a little, too, since Parent actually seems to use the alleged identity $J^T(JJ^T)^{-1}=(J^TJ)^{-1}J^T$ in equation 5.20, where he derives the pseudoinverse's relevance for solving the inverse kinematics problem. He computes everything with the left inverse but than concludes with using the right inverse. I guess that works conceptually because they're both pseudoinverses, even if it doesn't make complete mathematical sense (to me and you at least). He seemed to have used the assumption of a square matrix as a trick for transforming the problem and then used the conclusion for a non-square matrix, which might be conceptually correct.

I guess it simply doesn't matter which of the two pseudoinverses we use, since only one of them ever exists (for a non-square Jacobian) anyway and if the left inverse would exist (making your above assumption true), that means you have more constraints than DoF and thus your system is overconstrained and there's no point in angle control.