MATLAB: Forward and inverse dynamics for robot, unable to build robot model.

forward dynamicsinverse dynamicsRobotics System Toolbox

Hello, I'm learning kinematics and dynamics using Robotic Toolbox Matlab. To perform dynamics (inverse and forward), first I have to build robot model. For that, I took Puma560 data and tried. Code is given below:
%define link mass
L(1).m = 4.43;
L(2).m = 10.2;
L(3).m = 4.8;
L(4).m = 1.18;
L(5).m = 0.32;
L(6).m = 0.13;
%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];
L(5).r = [ 0 0 0];
L(6).r = [ 0 0 0.01];
%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];
L(5).I = [ 0.216e-3 0.216e-3 0.348e-3 0 0 0];
L(6).I = [ 0.437e-3 0.437e-3 0.013e-3 0 0 0];
%define motor inertia
L(1).Jm = 200e-6;
L(2).Jm = 200e-6;
L(3).Jm = 200e-6;
L(4).Jm = 33e-6;
L(5).Jm = 33e-6;
L(6).Jm = 33e-6;
%define gear ratio
L(1).G = -62.6111;
L(2).G = 107.815;
L(3).G = -53.7063;
L(4).G = 76.0364;
L(5).G = 71.923;
L(6).G = 76.686;
% motor viscous friction
L(1).B = 1.48e-3;
L(2).B = .817e-3;
L(3).B = 1.38e-3;
L(4).B = 71.2e-6;
L(5).B = 82.6e-6;
L(6).B = 36.7e-6;
% motor Coulomb friction
L(1).Tc = [ .395 -.435];
L(2).Tc = [ .126 -.071];
L(3).Tc = [ .132 -.105];
L(4).Tc = [ 11.2e-3 -16.9e-3];
L(5).Tc = [ 9.26e-3 -14.5e-3];
L(6).Tc = [ 3.96e-3 -10.5e-3];
% create links using D-H parameters
L(1).l = Link([ 0 0 0 pi/2 0], 'standard');
L(2).l = Link([ 0 .15005 .4318 0 0], 'standard');
L(3).l = Link([0 .0203 0 -pi/2 0], 'standard');
L(4).l = Link([0 .4318 0 pi/2 0], 'standard');
L(5).l = Link([0 0 0 -pi/2 0], 'standard');
L(6).l = Link([0 0 0 0 0], 'standard');
% set limits for joints
L(1).l.qlim=[deg2rad(-160) deg2rad(160)];
L(2).l.qlim=[deg2rad(-125) deg2rad(125)];
L(3).l.qlim=[deg2rad(-270) deg2rad(90)];
%build the robot model
puma560 = SerialLink(L, 'name','Puma 560');
But when I run this, it shows error. " _ Error using SerialLink (line 333) unknown type passed to robot_"
Can anybody suggest me what to do to complete my forward and inverse dynamics analysis and plotting them?
Thanks.

Best Answer

I solved this answer and code should be like this.
% 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(5) = Link([0 0 0 -pi/2 0], 'standard');
L(6) = Link([0 0 0 0 0], 'standard');
%define link mass
L(1).m = 4.43;
L(2).m = 10.2;
L(3).m = 4.8;
L(4).m = 1.18;
L(5).m = 0.32;
L(6).m = 0.13;
%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];
L(5).r = [ 0 0 0];
L(6).r = [ 0 0 0.01];
%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];
L(5).I = [ 0.216e-3 0.216e-3 0.348e-3 0 0 0];
L(6).I = [ 0.437e-3 0.437e-3 0.013e-3 0 0 0];
%define motor inertia
L(1).Jm = 200e-6;
L(2).Jm = 200e-6;
L(3).Jm = 200e-6;
L(4).Jm = 33e-6;
L(5).Jm = 33e-6;
L(6).Jm = 33e-6;
%define gear ratio
L(1).G = -62.6111;
L(2).G = 107.815;
L(3).G = -53.7063;
L(4).G = 76.0364;
L(5).G = 71.923;
L(6).G = 76.686;
% motor viscous friction
L(1).B = 1.48e-3;
L(2).B = .817e-3;
L(3).B = 1.38e-3;
L(4).B = 71.2e-6;
L(5).B = 82.6e-6;
L(6).B = 36.7e-6;
% motor Coulomb friction
L(1).Tc = [ .395 -.435];
L(2).Tc = [ .126 -.071];
L(3).Tc = [ .132 -.105];
L(4).Tc = [ 11.2e-3 -16.9e-3];
L(5).Tc = [ 9.26e-3 -14.5e-3];
L(6).Tc = [ 3.96e-3 -10.5e-3];
% set limits for joints
L(1).qlim=[deg2rad(-160) deg2rad(160)];
L(2).qlim=[deg2rad(-125) deg2rad(125)];
L(3).qlim=[deg2rad(-270) deg2rad(90)];
%build the robot model
puma560 = SerialLink(L, 'name','Puma 560');