MATLAB Answers

0

How to generate a function which can give the transformation matrix for given DH parameters?

Asked by Shashank Thakker on 2 Oct 2015
Latest activity Answered by Pushpendra Gupta on 22 Jul 2019
I want to generate a function which can give transformation matrix for given DH parameters. The cache is the function should valid for any number of links. It means number of links are variable. Like if I want take 4 ,5 or6 any no of links it should take dh parameters for all the links and should give the final transformation matrix.

  0 Comments

Sign in to comment.

1 Answer

Answer by Pushpendra Gupta on 22 Jul 2019

syms L1 L2 L3 L4 L5 Q1 Q2 Q3 Q4 Q5
alphaa=[0,0,-90,0,+90]; % this is the alpha value for all the link
a=[L1,L2, L3, L4, L5]; % Length of the Link
d=[0,0,0,0,0]; %Offset
Q=[Q1,Q2,Q3,Q4,Q5]; % joint angle variation
%%Transformation Matrices
for i=1:5
switch i
case 1
T01= [cos(Q(1,i)),-sin(Q(1,i))*cosd(alphaa(1,i)),sind(alphaa(1,i))*sin(Q(1,i)),a(1,i)*cos(Q(1,i));sin(Q(1,i)),cos(Q(1,i)).*cosd(alphaa(1,i)),-sind(alphaa(1,i))*cos(Q(1,i)),sin(Q(1,i))*a(1,i);0,sind(alphaa(1,i)),cosd(alphaa(1,i)),d(1,i);0,0,0,1];
case 2
T12= [cos(Q(1,i)),-sin(Q(1,i))*cosd(alphaa(1,i)),sind(alphaa(1,i))*sin(Q(1,i)),a(1,i)*cos(Q(1,i));sin(Q(1,i)),cos(Q(1,i)).*cosd(alphaa(1,i)),-sind(alphaa(1,i))*cos(Q(1,i)),sin(Q(1,i))*a(1,i);0,sind(alphaa(1,i)),cosd(alphaa(1,i)),d(1,i);0,0,0,1];
case 3
T23= [cos(Q(1,i)),-sin(Q(1,i))*cosd(alphaa(1,i)),sind(alphaa(1,i))*sin(Q(1,i)),a(1,i)*cos(Q(1,i));sin(Q(1,i)),cos(Q(1,i)).*cosd(alphaa(1,i)),-sind(alphaa(1,i))*cos(Q(1,i)),sin(Q(1,i))*a(1,i);0,sind(alphaa(1,i)),cosd(alphaa(1,i)),d(1,i);0,0,0,1];
case 4
T34= [cos(Q(1,i)),-sin(Q(1,i))*cosd(alphaa(1,i)),sind(alphaa(1,i))*sin(Q(1,i)),a(1,i)*cos(Q(1,i));sin(Q(1,i)),cos(Q(1,i)).*cosd(alphaa(1,i)),-sind(alphaa(1,i))*cos(Q(1,i)),sin(Q(1,i))*a(1,i);0,sind(alphaa(1,i)),cosd(alphaa(1,i)),d(1,i);0,0,0,1];
case 5
T45= [cos(Q(1,i)),-sin(Q(1,i))*cosd(alphaa(1,i)),sind(alphaa(1,i))*sin(Q(1,i)),a(1,i)*cos(Q(1,i));sin(Q(1,i)),cos(Q(1,i)).*cosd(alphaa(1,i)),-sind(alphaa(1,i))*cos(Q(1,i)),sin(Q(1,i))*a(1,i);0,sind(alphaa(1,i)),cosd(alphaa(1,i)),d(1,i);0,0,0,1];
end
end
T01 % first link with respect to base
T02= T01*T12
you are looking for T05 then
T05= T01*T12*T23*T34*T45
This is for symbolic form in case of numeric evaluation use makehgtform

  0 Comments

Sign in to comment.