# showing error while using inverse kinematics “ikine” for 4 dof robotic arm

I want to do forward dynamics but before that I got struck in inverse kinematics for 4 dof. My code is given below:

preach = [0.2, 0.2, 0.3];
% create links using D-H parameters
L(1) = Link([ 0 0 0 pi/2 0], 'standard');
L(2) = Link([ 0 .15005 .4318 0 0], 'standard');
L(3) = Link([0 .0203 0 -pi/2 0], 'standard');
L(4) = Link([0 .4318 0 pi/2 0], 'standard');
L(1).m = 4.43;
L(2).m = 10.2;
L(3).m = 4.8;
L(4).m = 1.18;
%define center of gravity
L(1).r = [ 0 0 -0.08];
L(2).r = [ -0.216 0 0.026];
L(3).r = [ 0 0 0.216];
L(4).r = [ 0 0.02 0];
%define link inertial as a 6-element vector
%interpreted in the order of [Ixx Iyy Izz Ixy Iyz Ixz]
L(1).I = [ 0.195 0.195 0.026 0 0 0];
L(2).I = [ 0.588 1.886 1.470 0 0 0];
L(3).I = [ 0.324 0.324 0.017 0 0 0];
L(4).I = [ 3.83e-3 2.5e-3 3.83e-3 0 0 0];
% set limits for joints
%build the robot model
qready = [0 -pi/6 pi/6 pi/3   ];
m = [1 1 1 1 0 0];   % mask matrix
t = [0:.056:2];
% do inverse kinematics
qreach =  rob.ikine(T0, preach, m);
%compute inverse dynamics using recursive Newton-Euler algorithm
tauf = rne(rob, q, qd, qdd);
% forward dynamics
[t1,Q,Qd] = rob.fdyn(2,tauf(5,:),q(5,:), qd(5,:));


But due to

qreach =  rob.ikine(T0, preach, m);


it shows error

Index exceeds matrix dimensions.

Error in SerialLink/jacobn (line 64) U = L(j).A(q(j)) * U;

Error in SerialLink/jacob0 (line 56) Jn = jacobn(robot, q); % Jacobian from joint to wrist space

Error in SerialLink/ikine (line 153) J0 = jacob0(robot, q);

Can anybody explain me why this is happening and how to resolve it.

Thanks.

• Index exceeds Matrix dimensions normally indicates that you are trying to access the index that is not in the matrix. Ex : (if you are trying to access somemat(50) even though the maximum length of somemat is 40. Please debug your code properly Hint:Print the matrix and check if it has the element that you are trying to access – the_parzival Dec 12 '16 at 9:42

In the Robotics Toolbox