Matlab

Thread Starter

beatsal

Joined Jan 21, 2018
289
Having problems with Matlab code; tried the forum but abswers were beyond me. Iam getting these errors doing a robot program any idea why?

Error using svd First input must be single or double. Error in pinv (line 18) [U,s,V] = svd(A,'econ'); Error in solution (line 25) dq=pinv(J_BF_inB)*b;
 

MrChips

Joined Oct 2, 2009
26,113
Having problems with Matlab code; tried the forum but abswers were beyond me. Iam getting these errors doing a robot program any idea why?

Error using svd First input must be single or double. Error in pinv (line 18) [U,s,V] = svd(A,'econ'); Error in solution (line 25) dq=pinv(J_BF_inB)*b;
There's not much to go on here.
Show us the entire code.
 

Thread Starter

beatsal

Joined Jan 21, 2018
289
Here is my code. It is inverse kinematics i.e. determine the joint angles of a 3-link roboy yo acieve a desired end position.

r=[0,0,0];
b=rGoal-r;
dq=pinv(J_BF_inB)*b;
tolerance =1e-4;
while dq >= 1e-4
dq=pinv(J_BF_inB)*b;
q=q+dq;
dr=J_BF_inB*dq;
r=r+dr;
b=rGoal-r;
end
 

Thread Starter

beatsal

Joined Jan 21, 2018
289
Sorry here is the code. The iterative loop does not converge.
//
r_BF_inB = @(alpha,beta,gamma)[...
-sin(beta + gamma) - sin(beta);...
sin(alpha)*(cos(beta + gamma) + cos(beta) + 1) + 1;...
-cos(alpha)*(cos(beta + gamma) + cos(beta) + 1)];

J_BF_inB = @(alpha,beta,gamma)[...
0, - cos(beta + gamma) - cos(beta), -cos(beta + gamma);...
cos(alpha)*(cos(beta + gamma) + cos(beta) + 1), -sin(alpha)*(sin(beta + gamma) + sin(beta)), -sin(beta + gamma)*sin(alpha);...
sin(alpha)*(cos(beta + gamma) + cos(beta) + 1), cos(alpha)*(sin(beta + gamma) + sin(beta)), sin(beta + gamma)*cos(alpha)];

% write an algorithm for the inverse kinematics problem to
% find the generalized coordinates q that gives the endeffector position rGoal =
% [0.2,0.5,-2]' and store it in qGoal
q0 = pi/180*([0,-30,60])';
rGoal = [0.2,0.5,-2]';
r=[0.1,0.1,0.1]';
n=0;
b=rGoal-r;
q=q0;
dr=1;
tolerance = 1e-4;
dq=pinv(J_BF_inB(q(1),q(2),q(3)))*b;
%while any(dr >= tolerance)
while any(dq >= tolerance)
%q(1)=q(1)+1e-4;
%q(2)=q(2)+1e-4;
%q(3)=q(3)+1e-4;
dq=pinv(J_BF_inB(q(1),q(2),q(3)))*b;
q=q+dq;
dr=J_BF_inB(q(1),q(2),q(3))*dq;
r=r+dr;
b=rGoal-r;
end
qGoal=q
//
 
Top