1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
clear;clc;
L=[4;3;2]; Theta=deg2rad([10;20;30]); X_d=[0.2;-0.3;-0.2]; W=[1;2;3]; dt=0.1; duration=5;
link(1)=Link('alpha',0,'a',0,'d',0,'modified'); link(2)=Link('alpha',0,'a',L(1),'d',0,'modified'); link(3)=Link('alpha',0,'a',L(2),'d',0,'modified'); bot=SerialLink(link,'name','robot','tool',[L(3),0,0]);
Theta_d_list=zeros([3,duration/dt]); Theta_list=zeros([3,duration/dt]); X_list=zeros([3,duration/dt]); J_det_list=zeros([1,duration/dt]); T_list=zeros([3,duration/dt]);
idex=1; for t=0:dt:duration J=[-L(1)*sin(Theta(1))-L(2)*sin(Theta(1)+Theta(2))-L(3)*sin(Theta(1)+Theta(2)+Theta(3))... -L(2)*sin(Theta(1)+Theta(2))-L(3)*sin(Theta(1)+Theta(2)+Theta(3))... -L(3)*sin(Theta(1)+Theta(2)+Theta(3)); L(1)*cos(Theta(1))+L(2)*cos(Theta(1)+Theta(2))+L(3)*cos(Theta(1)+Theta(2)+Theta(3))... L(2)*cos(Theta(1)+Theta(2))+L(3)*cos(Theta(1)+Theta(2)+Theta(3))... L(3)*cos(Theta(1)+Theta(2)+Theta(3)); 1 1 1;]; Theta_d=J\X_d; X=[L(3)*cos(Theta(1)+Theta(2)+Theta(3))+L(2)*cos(Theta(1)+Theta(2))+L(1)*cos(Theta(1)); L(3)*sin(Theta(1)+Theta(2)+Theta(3))+L(2)*sin(Theta(1)+Theta(2))+L(1)*sin(Theta(1)); Theta(1)+Theta(2)+Theta(3)]; J_det=det(J); T=J'*W; Theta_d_list(:,idex)=Theta_d; Theta_list(:,idex)=rad2deg(Theta); X_list(:,idex)=X; J_det_list(idex)=det(J); T_list(:,idex)=T; Theta=Theta+Theta_d*dt; idex=idex+1; end
t=0:dt:duration;
figure plot(t,Theta_d_list) title('3个主动关节速率与时间的关系') grid on xlabel('t/s') ylabel('$\dot{\Theta }/(rad\cdot s^{-1} )$','Interpreter','latex') legend('$\dot{\theta }_1$','$\dot{\theta }_2$','$\dot{\theta }_3$'... ,'Interpreter','latex')
figure plot(t,Theta_list) title('3个主动关节角与时间的关系') grid on xlabel('t/s') ylabel('$\Theta/^{\circ}$','Interpreter','latex') legend('$\theta_1$','$\theta_2$','$\theta_3$', ... 'Interpreter','latex')
figure plot(t,X_list) title('3个笛卡尔分量与时间的关系') grid on xlabel('t/s') ylabel('笛卡尔分量') legend('$x/m$','$y/m$','$\phi/rad $', ... 'Interpreter','latex')
figure plot(t,J_det_list) title('雅可比矩阵行列式与时间的关系') grid on xlabel('t/s') ylabel('$\left | J \right | $','Interpreter','latex')
figure plot(t,T_list) title('3个活动关节力矩与时间的关系') grid on xlabel('t/s') ylabel('$T/(N\cdot m)$','Interpreter','latex') legend('$\tau_1$','$\tau_2$','$\tau_3$', ... 'Interpreter','latex')
figure bot.plot(deg2rad(Theta_list)','view','top','movie','rob.mp4')
clear;clc;
L(1)=Link('alpha',0,'a',0,'d',0,'modified'); L(2)=Link('alpha',0,'a',4,'d',0,'modified'); L(3)=Link('alpha',0,'a',3,'d',0,'modified'); bot=SerialLink(L,'name','robot','tool',[2,0,0]);
Theta_0s=deg2rad([10;20;30]);
Theta_5s=deg2rad([11.8810745317428;18.0197158094528;-27.1965698542779]);
j0_0s=bot.jacob0(Theta_0s'); j0_0s([1,2,6],:) j0_5s=bot.jacob0(Theta_5s'); j0_5s([1,2,6],:)
|