(1)基础函数
Q = Robot.rne(q,qd,qdd,'slow');
(2)程序
注:因DH建模、动力学参数数值、单位等问题,最终结果只作为参考值。
clear;clc;close all;
%轴1-----------------------------------------------------------------------
L(1)=Link('revolute','d',124,'a',0,'alpha',-pi/2);
L(1).I=[0 0 0;0 0.67 0;0 0 0];
L(1).r=[0 60 0];
L(1).m=10;
L(1).Jm=200;
L(1).G=66.6111;
L(1).B=1.48;
L(1).Tc=[395 -435];
L(1).qlim=[-165/180*pi,165/180*pi];
%轴2-----------------------------------------------------------------------
L(2)=Link('revolute','d',0,'a',270,'alpha',0,'offset',-pi/2);
L(2).I=[0.45 0 0;0 0.764 0;0 0 0.539];
L(2).r=[-135 0 0];
L(2).m=17.4;
L(2).Jm=200;
L(2).G=107.815;
L(2).B=1.48;
L(2).Tc=[395 -435];
L(2).qlim=[-110/180*pi,110/180*pi];
%轴3-----------------------------------------------------------------------
L(3)=Link('revolute','d',0,'a',70,'alpha',-pi/2);
L(3).I=[0.006e-2 0 0;0 0.07e-2 0;0 0 0.06725e-2];
L(3).r=[0 0 50];
L(3).m=4.8;
L(3).Jm=200;
L(3).G=53.7073;
L(3).B=1.48;
L(3).Tc=[395 -435];
L(3).qlim=[-90/180*pi,70/180*pi];
%轴4-----------------------------------------------------------------------
L(4)=Link('revolute','d',302,'a',0,'alpha',pi/2);
L(4).I=[1.8e-2 0 0;0 1.3e-2 0;0 0 1.8e-2];
L(4).r=[0 -50 0];
L(4).m=0.82;
L(4).Jm=33;
L(4).G=60.0364;
L(4).B=1.48;
L(4).Tc=[395 -435];
L(4).qlim=[-160/180*pi,160/180*pi];
%轴5-----------------------------------------------------------------------
L(5)=Link('revolute','d',0,'a',0,'alpha',-pi/2);
L(5).I=[0.3e-2 0 0;0 0.4e-2 0;0 0 0.3e-2];
L(5).r=[0 0 32];
L(5).m=0.32;
L(5).Jm=33;
L(5).G=69.923;
L(5).B=1.48;
L(5).Tc=[395 -435];
L(5).qlim=[-120/180*pi,120/180*pi];
%轴6-----------------------------------------------------------------------
L(6)=Link('revolute','d',72,'a',0,'alpha',0);
L(6).I=[0.15e-2 0 0;0 0.15e-2 0;0 0 0.04e-2];
L(6).r=[0 0 -10];
L(6).m=0.09;
L(6).Jm=33;
L(6).G=78.686;
L(6).B=1.48;
L(6).Tc=[395 -435];
L(6).qlim=[-400/180*pi,400/180*pi];
%--------------------------------------------------------------------------
Robot=SerialLink(L,'name','ABB120');
Robot.base=transl(0,0,166);
v=[90 20];%观看视角【方位角,仰角】
w=[-800 800 -800 800 0 1000];%工作空间大小
t=0:1/50:2;%设置运行时间
q1=[0 0 -90 0 0 0]/180*pi;%初始位置
q2=[0 90 -90 0 0 0]/180*pi;%终点位置
qd1=[0 0 0 0 0 0]/180*pi;%六个关节初始速度
qd2=[0 0 0 0 0 0]/180*pi;%六个关节终止速度
[q,qd,qdd]=jtraj(q1,q2,t,qd1,qd2);
Q = Robot.rne(q,qd,qdd,'slow');%获得每个时间点所需要的关节力矩
T=Robot.fkine(q);
set(gcf,'position',[200 100 1200 600])
subplot(3,3,3);
plot(t,q*180/pi);
xlabel('时间/s');ylabel('位置/deg');
legend('Joint1','Joint2','Joint3','Joint4','Joint5','Joint6');
grid on
subplot(3,3,6);
plot(t,qd*180/pi);
xlabel('时间/s');ylabel('速度/[deg/s]');
legend('Joint1','Joint2','Joint3','Joint4','Joint5','Joint6');
grid on
subplot(3,3,9);
plot(t,qdd*180/pi);
xlabel('时间/s');ylabel('加速度/[deg/s^2]');
legend('Joint1','Joint2','Joint3','Joint4','Joint5','Joint6');
grid on
subplot(3,3,[7 8]);
plot(t,Q);
xlabel('时间/s');ylabel('转矩');
legend('Joint1','Joint2','Joint3','Joint4','Joint5','Joint6');
grid on
subplot(3,3,[1 2 4 5]);
for i=1:size(q)
TT(i,:)=T(1,i).t;
end
plot3(TT(:,1),TT(:,2),TT(:,3),'-b','LineWidth',2);
hold on
Robot.plot3d(q,'tilesize',1,'workspace',w,'path','D:\Desktop\ABB120机器人仿真\RobotLink','nowrist','view',v);