“Index exceeds array bounds” problem (MATLAB code for Puma 260 Manipulator: spherical path) [closed]

asked 2020-12-17 08:46:08 -0500

elish gravatar image

I have a problem with this Matlab code. It tells me there is an error on line 44: SURF (i, j, :) = TR (:, 4); The problem is that the index at position 2 exceeds the bounds of the array (must not exceed 1). I tried to write an array with zeros but the code doesn't run the same. Does anyone know how to fix the problem and explain it to me? Thank you so much.

%%% 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');
T_1 = trotz(a1)*transl(0,0,13)*trotx(-pi/2);
T_2 = trotz(a2)*transl(8,0,0);
T_3 = trotz(a3+pi/2)*transl(0,0,-2)*trotx(pi/2);
T_4 = trotz(a4)*transl(0,0,8)*trotx(-pi/2);
T_5 = trotz(a5-pi/2)*trotx(pi/2);
T_6 = trotz(a6);
%%% Forward kinematics
T = T_1*T_2*T_3*T_4*T_5*T_6;
%%% Now, to substitute the symbols by numerical values, we can use the ‘subs’ function. For example, if i want to set all variables to zero, i can execute the following substitution:
subs(T, {a1, a2, a3, a4, a5, a5}, {0, 0, 0, 0, 0, 0}) 
%%% Alternatively we can build the robot using the SerialLink function
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 = 'ROBOT';
Puma260.plot([0 0 0 0 0 0]);
Puma260.fkine([a1 a2 a3 a3 a4 a5]);
Puma260.plot([0 0 0 0 pi/2 0]);
xlabel('X (in inch)');
ylabel('Y (in inch)');
zlabel('Z (in inch)');
title('Workspace of ROBOT');
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));
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by jarvisschultz
close date 2020-12-17 11:00:43.039530