Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.

9 Ansichten (letzte 30 Tage)
Good evening everyone.
I have to implement in MATLAB/SIMULINK the kinematic inversion algorithm with inverse (and transpose) of the jacobian. I defined the trajectory to follow with the trapveltraj function and obtained the relative values ​​of position, speed, acceleration, etc. of the end effector. When I start the simulink model it gives completely wrong results and the error :"Warning: Matrix is ​​singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.". I tried to change solver but it didn't solve the problem. Below is the code I used and the simulink model. Thanks a lot to whoever will help me.
the code:
% IMPLEMENTARE IN MATLAB GLI ALGORITMI PER L'IINVERSIONE
% CINEMATICA CON INVERSA E TRASPOSTA DELLO JACOBIANO LUNGO LA TRAIETTORIA.
% ADOTTARE LA REGOLA DI INTEGRAZIONE NUMERICA DI EULERO CON
% TEMPO DI INTEGRAZIONE DI 1 MS.
close all
clc
% numero di giunti
n=4;
q=zeros(n,N);
% vettore variabili di giunto (th1 , th2 , d3 , th4)
q(:,1) = [90/180*pi -90/180*pi 0 0/180*pi]';
q(:,2) = [60/180*pi -120/180*pi 0 0/180*pi]';
q(:,3) = [15/180*pi -30/180*pi 0 0/180*pi]';
q(:,4)= [45/180*pi 90/180*pi 0 0/180*pi]';
q(:,5) = [45/180*pi -60/180*pi 0 0/180*pi]';
a=[0.5 0.5 0 0]';
alpha=[0 pi 0 0]';
d=[0 0 q(3,1) 0]';
theta=[q(1,1) q(2,1) 0 q(4,1)]';
DH=[a alpha d theta];
% definizione traiettoria
x = -10: 1 : 10;
raggio = 10;
y = sqrt (raggio^2 -x .^ 2);
k = zeros(length(x));
z = k(1,:);
punti_di_percorso = [0 70 90 90 50 50 20 -10 x 10 0;
90 90 70 50 40 -30 -60 -60 y 30 90;
0 0 30 30 50 50 10 10 z 0 0];
[q,qd,qdd,tvec,pp] = trapveltraj(punti_di_percorso, 1000);
Jacobian_scara_rectangular = Jacobian_Scara(DH);
Jacobian_scara_square = [Jacobian_scara_rectangular(1,:); Jacobian_scara_rectangular(2,:); Jacobian_scara_rectangular(3,:); Jacobian_scara_rectangular(6,:)];
K = [100 0 0 0; 0 100 0 0 ; 0 0 100 0; 0 0 0 100];
inversa_jacobiano = inv(Jacobian_scara_square);
q0 = [0 -90/180*pi -0.5 0]';
a = zeros(1,1000);
tvec = tvec';
zero=zeros(1,1000);
q1 = q';
q2 = qd';
xd = [tvec q1 zero'];
dxd = [tvec q2 zero'];
the matlab functions:
1)
function xe = fcn(q)
xe = zeros(4,1);
a=[0.5 0.5 0 0]';
alpha=[0 pi 0 0]';
d=[0 0 q(3,1) 0]';
theta=[q(1,1) q(2,1) 0 q(4,1)]';
DH=[a alpha d theta];
cinematica_diretta=DirectKinematics(DH);
xe(1)=cinematica_diretta(1,4,4);
xe(2)=cinematica_diretta(2,4,4);
xe(3)=cinematica_diretta(3,4,4);
xe(4)=q(1)+q(2)+q(4);
end
2)
function j_inversa=fcn(q)
a=[0.5 0.5 0 0]';
alpha=[0 pi 0 0]';
d=[0 0 q(3,1) 0]';
theta=[q(1,1) q(2,1) 0 q(4,1)]';
DH=[a alpha d theta];
Jacobian_scara_rectangular = Jacobian_Scara(DH);
Jacobian_scara_square = [Jacobian_scara_rectangular(1,:); Jacobian_scara_rectangular(2,:); Jacobian_scara_rectangular(3,:); Jacobian_scara_rectangular(6,:)];
j_inversa = inv(Jacobian_scara_square);
end

Antworten (1)

Nadia Shaik
Nadia Shaik am 7 Mär. 2023
Hi Lorenzo,
I understand that you are getting the below warning message while running the Simulink model.
Warning: Matrix is close to singular or badly scaled
A common cause for this warning is that a program or function you run is using a matrix that is badly conditioned (difficult to invert) as one of the arguments to the backslash (\) or forward slash (/) operators, which are commonly used to solve systems of linear equations.
As a workaround, stop MATLAB on the line where the warning occurs. Examine the line for instances of the two slash operators. If you find one, determine the condition number of the coefficient matrix (the matrix on the left side of the backslash (\) or on the right side of the forward slash (/) using the COND function. Large results for the condition number indicate the matrix is extremely ill-conditioned. You should verify (using the matrix multiplication operator (*)) that the result of solving the system is numerically reliable.
I hope the above information resolves your query.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by