最近准备研究一下7自由度机械臂,先做一些基本分析,后续会持续更新其工作空间、动力学模型和基于优化理论的轨迹规划设计。
%Author:easyR
%Date:2019/6/18
%dh:SDH Table
%构型数据参考《基于matlab的七自由度机器人运动学及工作空间仿真》
%徐小龙 《新技术新工艺》设计与计算
%parameters of coordinate
clc;clear all;
tic;
% syms q1 q2 q3 q4 q5 q6 q7 real
% structure parameters
a1=0.165; a4=0.2; d2=0.02; d4=0.098; d5=0.65;
alpha0=0;alpha1=-pi/2;alpha2=pi/2;alpha3=-pi/2;alpha4=-pi/2;alpha5=pi/2;alpha6=-pi/2;
d=[0 d2 0 d4 d5 0 0];
a=[0 a1 0 0 a4 0 0];
alpha=[alpha0 alpha1 alpha2 alpha3 alpha4 alpha5 alpha6];
q=[0 0 0 0 0 0 0]; % standup
disp('Output the DH parameters Table:')
dh=[a' alpha' q' d']
[T,T10,T20,T30,T40,T50,T60,T70]=myfunTransMatrix(dh,0);
myfunPostureDrawing(T10,T20,T30,T40,T50,T60,T70);
toc;
%··············································
%%Matlab Robot Tool Box
% θ d a α offset
L(1)=Link([0 0 0 0 0 ],'sdh');
L(2)=Link([0 d2 a1 alpha1 0 ],'sdh');
L(3)=Link([0 0 0 alpha2 0 ],'sdh');
L(4)=Link([0 d4 0 alpha3 0 ],'sdh');
L(5)=Link([0 d5 a4 alpha4 0 ],'sdh');
L(6)=Link([0 0 0 alpha5 0 ],'sdh');
L(7)=Link([0 0 0 alpha6 0 ],'sdh');
robot=SerialLink(L,'name','robot7R','manufacturer','Unimation','comment','AK&B');
robot.display(); %display MDH table
robot.plot(q);
%················································
function myfunPostureDrawing(T10,T20,T30,T40,T50,T60,T70)
%Method:MDH or SDH
%Goal:compute transform matrix
%Author:easyR
%Date:2019/2/20
%dh:MDH Table
%T:the matrix of Transform,the valve from 'myfunTransMatrix'
%% Drawing the posture of manipulators
%draw the posture of robot
x = [T10(1,4) T20(1,4) T30(1,4) T40(1,4) T50(1,4) T60(1,4) T70(1,4)];
y = [T10(2,4) T20(2,4) T30(2,4) T40(2,4) T50(2,4) T60(2,4) T70(2,4)];
z = [T10(3,4) T20(3,4) T30(3,4) T40(3,4) T50(3,4) T60(3,4) T70(3,4)];
%draw the toolpoint coordinate
px=T70*[0.05;0;0;1]; py=T70*[0;0.05;0;1]; pz=T70*[0;0;0.05;1]; %'50'is properties of coordinate
px1=[T70(1,4),px(1,1)];py1=[T70(2,4),px(2,1)];pz1=[T70(3,4),px(3,1)];
px2=[T70(1,4),py(1,1)];py2=[T70(2,4),py(2,1)];pz2=[T70(3,4),py(3,1)];
px3=[T70(1,4),pz(1,1)];py3=[T70(2,4),pz(2,1)];pz3=[T70(3,4),pz(3,1)];
%%
%drawing figures
plot3(x,y,z,'o','linewidth',8);
hold on
%set coordinate XYZ
plot3(px1,py1,pz1,'r','LineWidth',3)
hold on
plot3(px2,py2,pz2,'g','LineWidth',3)
hold on
plot3(px3,py3,pz3,'b','LineWidth',3)
title("Forward Kinematics")
xlabel("x(m)")
ylabel("y(m)")
zlabel("z(m)")
plot3(x,y,z, 'y','Linewidth',5);
grid on;
grid on;
end
function [T,T10,T20,T30,T40,T50,T60,T70]=myfunTransMatrix(dh,DHflg)
%Method:MDH or SDH
%Goal:compute transform matrix
%Author:easyR
%Date:2019/1/25
%dh:MDH or SDH Table
%DHflg:input 0 or 1,equal sdh or mdh
%T:Transform Matrix from endpoint to basement
for k=1:7
for i=1:k
if DHflg==0
T(:,:,k)=myfunSDHMatrix( dh(i,1),dh(i,2),dh(i,3),dh(i,4)); % SDH
elseif DHflg==1
T(:,:,k)=myfunMatrixTrans( dh(i,1),dh(i,2),dh(i,3),dh(i,4)); %MDH
elseif (DHflg~=1 && DHflg~=1)
disp('Error input');
break;
end
end
end
disp('display each transform matrix Tn:');
% transform matrix
T10=(T(:,:,1));T21=(T(:,:,2));T32=(T(:,:,3));T43=(T(:,:,4));T54=(T(:,:,5));T65=(T(:,:,6));T76=(T(:,:,7));
T20=T10*T21;T30=T20*T32;T40=T30*T43;T50=T40*T54;T60=T50*T65;T70=T60*T76;
end
%%
function [T]=myfunMatrixTrans(a,alpha,theta,d)
%Method:MDH
%Goal:compute transform matrix
%Author:easyR
%Date:2019/1/25
T=[
cos(theta), -sin(theta), 0, a;
sin(theta)*cos(alpha),cos(theta)*cos(alpha),-sin(alpha),-sin(alpha)*d;
sin(theta)*sin(alpha),cos(theta)*sin(alpha), cos(alpha), cos(alpha)*d;
0, 0, 0, 1
];
end
%%
function [Ai]=myfunSDHMatrix(a,alpha,q,d)
%%
%Transform matrix in SDH coordinate
%Ai,is the transform matrix between two coordinate
Ai=[cos(q),-sin(q)*cos(alpha), sin(q)*sin(alpha),a*cos(q);
sin(q), cos(q)*cos(alpha),-cos(q)*sin(alpha),a*sin(q);
0, sin(alpha), cos(alpha), d;
0, 0, 0, 1
];
end
Output the DH parameters Table:
dh =
0 0 0 0
0.1650 -1.5708 0 0.0200
0 1.5708 0 0
0 -1.5708 0 0.0980
0.2000 -1.5708 0 0.6500
0 1.5708 0 0
0 -1.5708 0 0
display each transform matrix Tn:
时间已过 3.166343 秒。
robot =
robot7R (7 axis, RRRRRRR, stdDH, fastRNE)
AK&B;
+---+-----------+-----------+-----------+-----------+-----------+
| j | theta | d | a | alpha | offset |
+---+-----------+-----------+-----------+-----------+-----------+
| 1| q1| 0| 0| 0| 0|
| 2| q2| 0.02| 0.165| -1.571| 0|
| 3| q3| 0| 0| 1.571| 0|
| 4| q4| 0.098| 0| -1.571| 0|
| 5| q5| 0.65| 0.2| -1.571| 0|
| 6| q6| 0| 0| 1.571| 0|
| 7| q7| 0| 0| -1.571| 0|
+---+-----------+-----------+-----------+-----------+-----------+
grav = 0 base = 1 0 0 0 tool = 1 0 0 0
0 0 1 0 0 0 1 0 0
9.81 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1