Errore nel codice per tracciare una sfera tramite braccio robotico

di Anonimizzato30025 il
1 risposte
Buongiorno a tutti,
il seguente codice Matlab alla riga che ho evidenziato in rosso, mi da il seguente errore:

"Index in position 2 exceeds array bounds (must not exceed 1)"

Qualcuno saprebbe come risolvere ?

clc;
clear;
%%% The standard DH-parameters of a link represent the transformation
%%%%%% rotz(theta_i)*trans(0,0,d_i)*trans(a_i,0,0)*rotx(alpha_i)
a1 = sym('a1');
a2 = sym('a2');
a3 = sym('a3');
a4 = sym('a4');
a5 = sym('a5');
a6 = sym('a6');

T01 = trotz(a1)*transl(0,0,13)*trotx(-pi/2);
T12 = trotz(a2)*transl(8,0,0);
T23 = trotz(a3+pi/2)*transl(0,0,-2)*trotx(pi/2);
T34 = trotz(a4)*transl(0,0,8)*trotx(-pi/2);
T45 = trotz(a5-pi/2)*trotx(pi/2);
T56 = trotz(a6);
%%% Forward kinematics
T06 = T01*T12*T23*T34*T45*T56;

%%% Now, to substitute the symbols by numerical values, we can use the
%%% ‘subs’ function. For example, if we want to set all variables to
%%% zero, we can execute the following substitution:
subs(T06, {a1, a2, a3, a4, a5, a5}, {0, 0, 0, 0, 0, 0})

L(1) = Link([0 13 0 -pi/2]);
L(2) = Link([0 0 8 0]);
L(3) = Link([0 -2 0 pi/2]);
L(4) = Link([0 8 0 -pi/2]);
L(5) = Link([0 0 0 pi/2]);
L(6) = Link([0 0 0 0]);

L(3).offset = pi/2;
L(5).offset = -pi/2;

Puma260 = SerialLink(L);
Puma260.name = 'Puma 260';
Puma260.plot([0 0 0 0 0 0]);
%%% We can obtain the general expression for the forward kinematics
Puma260.fkine([a1 a2 a3 a3 a4 a5]);

%%%QUESTION 4:
%%%%%% To obtain the workspace, we can fixa3and vary a1and a2to
%%%calculate the end-effector’sposition and plot it using the
%%% surffunction.

Puma260.plot([0 0 0 0 pi/2 0]);

xlabel('X (in inch)');
ylabel('Y (in inch)');
zlabel('Z (in inch)');
title('Workspace of Puma 260');

hold on;

N=30;

for i= 1:N+1
for j= 1:N+1
TR = Puma260.fkine([pi*(i-1)/N pi*(j-1)/N+pi/2 0 0 pi/2 0]);
SURF(i,j,:) = TR(:,4);
end
end

surf(SURF(:,:,1), SURF(:,:,2), SURF(:,:,3));

1 Risposte

  • Hai provato ad eseguire il programma in modalità debug?
    Hai verificato il contenuto delle matrici?
    Hai consultato la documentazione della funzione "surf" per capire quali input sono richiesti e di quali dimensioni?
    Hai confrontato il tipo / dimensione dei parametri che invece fornisci in input alla funzione "surf"?

    Il tuo codice sembra usate funzioni di toolboxes di terze parti (ROBOTICS TOOLBOX? Puma260?) e, probabilmente per cui è impossibile eseguirlo per individuare l'errore
Devi accedere o registrarti per scrivere nel forum
1 risposte