代码复制的有问题,详细见本楼,谢谢。
clc;clear;
DR=pi/180;
%time
j = 1;
for i = 0 : 0.1 : 2
%input
theta= 45 * DR *(1+6*exp((-1)*i/0.3)-8*exp((-1)*i/0.4));
theta_d= (-9*pi)/20*exp(-0.3*i)+20*exp(-2.5*i);
theta_dd= (27*pi/200)*exp(-0.3*i) - 50*exp(-2.5*i);
% DH parameters
the(1) = theta*DR; d(1)=2; a(1)=0; alp(1)=0;
the(2) = theta*DR; d(2)=0; a(2)=0; alp(2)=90*DR;
the(3) = theta*DR; d(3)=0; a(3)=3; alp(3)=0;
the(4) = 0; d(4)=0; a(4)=4; alp(4)=0;
%base link
w00=[0;0;0]; v00=[0;0;0]; w00d=[0;0;0];v00d=[0;9.8;0];
% rotation matrix
T01=[cos(the(1)), (-1)*sin(the(1)), 0, a(1); sin(the(1))*cos(alp(1)), cos(the(1))*cos(alp(1)), -sin(alp(1)), -sin(alp(1))*d(1); sin(the(1))*sin(alp(1)), cos(t