# SVD_HH::calculate

 Submitted by threelight on Mon, 2008-08-18 16:07

Hello,

which paramter of the function SVD_HH::calculate contains the mapped joint velocities from the pseudo inverse of the jacobian?
(the pseudo inverse maps cartesian velocities to joint velocities and I need to get access to these joint velocities).

### SVD_HH::calculate

On Monday 18 August 2008 18:07:43 threelight wrote:
> Hello,
>
> which paramter of the function SVD_HH::calculate contains the mapped joint
> velocities from the pseudo inverse of the jacobian? (the pseudo inverse
> maps cartesian velocities to joint velocities and I need to get access to
> these joint velocities).

The svd does not return the joint velocities, it only performs an Singular
Value Decomposition of the jacobian. If you use this class you have to
calculate the jointvelocities yourself using the results of the svd.

If you want to calculate the jointvelocities from a cartesian velocity, you
should use a chainiksolvervel class.

Ruben

### ah, sorry, I mixed

ah, sorry, I mixed something up. What I mean is:

I just want to build the pseudoinverse of the jacobian. I thought that this is done in the SVD_HH::calculate function?

The JntToJac-function creates a jacobian with the current joint values as input and returns a jacobian. Now I want to get the pseudoinverse of this jacobian.

### ah, sorry, I mixed

On Tuesday 19 August 2008 14:00:26 threelight wrote:
> ah, sorry, I mixed something up. What I mean is:
>
> I just want to build the pseudoinverse of the jacobian. I thought that this
> is done in the SVD_HH::calculate function?
>
> The JntToJac-function creates a jacobian with the current joint values as
> input and returns a jacobian. Now I want to get the pseudoinverse of this
> jacobian.

check and
on how to
calculate the pseudoinverse from the singular value decomposition.

Or look into the code of chainiksolvervel_pinv, which does the pseudo inverse
calculation from the singular value decomposition.

Ruben

### ok, I have 2 options: 1.)

ok, I have 2 options:

1.) building the pseudo inverse from U,S,V served by the calculate function

2.) get the pseudo inverse directly from the ChainIkSolverVel_pinv::CartToJnt-function.

I think the second way would be easier, but I don't understand your code. A short explanation of what happens in this function would be helpful.

### ok, I have 2 options:

On Wednesday 20 August 2008 10:24:41 threelight wrote:
> 1.)
> X-BeenThere: orocos-users [..] ...
> X-Mailman-Version: 2.1.5
> Precedence: list
> List-Id: Orocos Users
> List-Unsubscribe:
> ,
> orocos-users-request [..] ...?subject=unsubscribe>
> List-Archive:
> List-Post: orocos-users [..] ...>
> List-Help:
> orocos-users-request [..] ...?subject=help>
> List-Subscribe:
> ,
> orocos-users-request [..] ...?subject=subscribe>
> Sender: orocos-users-bounces [..] ...
> Errors-To: orocos-users-bounces [..] ...
>
>
> ok, I have 2 options:
>
> 1.) building the pseudo inverse from U,S,V served by the calculate function
>
> 2.) get the pseudo inverse directly from the
> ChainIkSolverVel_pinv::CartToJnt-function.
>
> I think the second way would be easier, but I don't understand your code. A
> short explanation of what happens in this function would be helpful.

I added the following comments to the code,
[code]
//Let the ChainJntToJacSolver calculate the jacobian "jac" for
//the current joint positions "q_in"
jnt2jac.JntToJac(q_in,jac);

//Do a singular value decomposition of "jac" with maximum
//iterations "maxiter", put the results in "U", "S" and "V"
//jac = U*S*Vt
int ret = svd.calculate(jac,U,S,V,maxiter);

double sum;
unsigned int i,j;

// We have to calculate qdot_out = jac_pinv*v_in
// Using the svd decomposition this becomes(jac_pinv=V*S_pinv*Ut):
// qdot_out = V*S_pinv*Ut*v_in

//first we calculate Ut*v_in
for (i=0;i sum = 0.0;
for (j=0;j sum+= U[j](i)*v_in(j);
}
//If the singular value is to small ( //set the inverted singular value to zero (truncated svd)
tmp(i) = sum*(fabs(S(i)) }
//tmp is now: tmp=S_pinv*Ut*v_in, we still have to premultiply
//it with V to get qdot_out
for (i=0;i sum = 0.0;
for (j=0;j sum+=V[i](j)*tmp(j);
}
//Put the result in qdot_out
qdot_out(i)=sum;
}
//return the return value of the svd decomposition
return ret;

if you still don't understand the code, please point out the part you do not
understand.

Ruben

### thanks!! this was helpful!

thanks!! this was helpful!