How to generate a function which can give the transformation matrix for given DH parameters?
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
Pushpendra Gupta
2019년 7월 22일
편집: Pushpendra Gupta
2021년 12월 26일
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 % Second Link with respect to base
%% You can simplify it too
simplify(T02)
%% you can find the position and Orientation of 5th Link with respect to Base Link using
T05 = T01*T12*T23*T34*T45;
simplify(T05)
This is for symbolic form in case of numeric evaluation use makehgtform
카테고리
도움말 센터 및 File Exchange에서 Manipulator Modeling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




