MATLAB: Rigid body tree D-H parameters

dh parametersrigid body treerobotics.jointrobotics.rigidbody

Hi I'm using matlab 2016/2017 with robotic toolbox installed. I've followed all the tutorials to learn how to use the RigidBody class. However, when I try to build my own rigid body tree it seems that something is wrong with my frames orientations. I don't know exactly how the DH parameter alpha for my third joint is not taken into account I've attached a picture of my kinematic diagram and a sample of my code. If somebody can help.
Thanks
if true
d67 = 0 ; %317.56 ;
alpha67 = 62*pi/180 ;
r67 = 0 ;
d78 = 0 ; % -53.03 ;
alpha78 = 17*pi/180 ;
r78 = 0 ; %172.23 ;
d89 = 0 ; %343.18 ;
r89 = 0 ; %38.74 ;
r910 = 0 ; % 211.5 ;
r1011 = 0 ; %334.95 ;
theta1112 = 65.98*pi/180 ;
r1112 = 0 ; % 10
dEe = 0 ; %100 ;
% DH = [ r_n alpha_n d_n theta_n]
DHparams = [0 alpha67 0 0;
r78 alpha78 d78 0;
r89 -pi/2 d89 0;
r910 0 0 0;
r1011 0 0 0;
r1112 -pi/2 0 theta1112;
0 0 dEe 0];
body1 = robotics.RigidBody('body1') ; % create the first body
jnt1 = robotics.Joint('jnt1','revolute'); % initial joint fixed to base
setFixedTransform(jnt1,DHparams(1,:),'dh') ; %
body1.Joint = jnt1;
Rcm = robotics.RigidBodyTree;
addBody(Rcm,body1,'base') ;
body2 = robotics.RigidBody('body2');
body3 = robotics.RigidBody('body3');
body4 = robotics.RigidBody('body4');
body5 = robotics.RigidBody('body5');
body6 = robotics.RigidBody('body6');
Endeff = robotics.RigidBody('endeffector');
jnt2 = robotics.Joint('jnt2','revolute');
jnt3 = robotics.Joint('jnt3','revolute');
jnt4 = robotics.Joint('jnt4','revolute');
jnt5 = robotics.Joint('jnt5','revolute');
jnt6 = robotics.Joint('jnt6','prismatic');
jnt3.JointAxis(3) ;
setFixedTransform(jnt2,DHparams(2,:),'dh');
setFixedTransform(jnt3,DHparams(3,:),'dh');
setFixedTransform(jnt4,DHparams(4,:),'dh');
setFixedTransform(jnt5,DHparams(5,:),'dh');
setFixedTransform(jnt6,DHparams(6,:),'dh');
setFixedTransform(Endeff.Joint,DHparams(7,:),'dh');
body2.Joint = jnt2;
body3.Joint = jnt3;
body4.Joint = jnt4;
body5.Joint = jnt5;
body6.Joint = jnt6;
addBody(Rcm,body2,'body1')
addBody(Rcm,body3,'body2')
addBody(Rcm,body4,'body3')
addBody(Rcm,body5,'body4')
addBody(Rcm,body6,'body5')
addBody(Rcm,Endeff,'body6')
show(Rcm);
axis on
view([90.000 0.000])
end

Best Answer

Better use the Homogeneous transformation matrix to take into account the theta angle.