六自由度機械臂五次多項式軌跡規劃(Fivejtraj_Function自編寫函數)

clear,clc,close all

format compact

robotModel=4;DH_Param;JointNum=length(DH);

ROCR6v2 關節23偏置

qlim=deg2rad([-179,179;-146,146;-146,146;-179,179;-179,179;-179,179]);

for i=1:JointNum

   L(i)=RevoluteMDH('d',DH(i,3),'a',DH(i,2),'alpha',deg2rad(DH(i,1)), ...

               'offset',deg2rad(DH(i,4)),'qlim',qlim(i,:));

end

robot=SerialLink(L,'name','robot');

robot.display();

robot =

robot:: 6 axis, RRRRRR, modDH, fastRNE                          

+---+-----------+-----------+-----------+-----------+-----------+

| j |     theta |         d |         a |     alpha |    offset |

+---+-----------+-----------+-----------+-----------+-----------+

|  1|         q1|     0.1215|          0|          0|          0|

|  2|         q2|     0.1225|          0|     1.5708|    -1.5708|

|  3|         q3|     -0.102|       -0.3|          0|          0|

|  4|         q4|       0.09|     -0.276|          0|    -1.5708|

|  5|         q5|       0.09|          0|     1.5708|          0|

|  6|         q6|      0.082|          0|    -1.5708|          0|

+---+-----------+-----------+-----------+-----------+-----------+

% 設置約束條件

Theta=[40,-30,-30,30,-15,20;

      0,15,0,10,20,50;

      -40,30,30,-20,30,30];

Velocity=[0,0,0,0,0,0;40,40,20,30,20,10;0,0,0,0,0,0];

Accle=[0,0,0,0,0,0;0,0,0,0,0,0;0,0,0,0,0,0];

[m,n]=size(Theta);

% 五次多項式軌跡規劃,定義插補次數n,根據驅動器支持的最大插補次數設定

Time=[0,0,0,0,0,0;5,5,5,5,5,5;10,10,10,10,10,10];

StopTime=Time(3,1);

FixedStep=0.2;

SimpleNum=0:FixedStep:StopTime;Cunt=length(SimpleNum);

for i=1:n

   %% 求每個關節角的五次多項式插補軌跡點

   [q(:,i),qd(:,i),qdd(:,i)] = Fivejtraj_Function(Theta(:,i),Time(:,i), ...

                               Velocity(:,i),Accle(:,i),FixedStep);

end

qT=q';vT=qd';aT=qdd';t=2000;

%% 求正解

T=robot.fkine(deg2rad(q));        %求正解,得到每次對應的空間位姿矩陣

JTA=transl(T);                  %空間位姿矩陣轉化為位置矩陣

rpy=tr2rpy(T,'xyz');            % T中提取姿態(rpy

% times=n*0.256*4; %ms

%% 繪制末端位置

W=[-700,+700,-700,+700,0,+1000]*0.001;

% 求約束角度的正解,獲取末端位姿

T1=robot.fkine(deg2rad(Theta(1,:)));

T2=robot.fkine(deg2rad(Theta(2,:)));

T3=robot.fkine(deg2rad(Theta(3,:)));

% 動態仿真

figure('Color',[1,1,1],'Position',[485,180,386,310],'Visible','on');

plot3(JTA(1:end,1), JTA(1:end,2), JTA(1:end,3),'b','LineWidth',1.5);

axis(W);   %設置坐標軸范圍

hold on;grid on;

plot3(T1.t(1),T1.t(2),T1.t(3),'o','color','r','LineWidth',2);%#7E2F8E

plot3(T2.t(1),T2.t(2),T2.t(3),'o','color','r','LineWidth',2);

plot3(T3.t(1),T3.t(2),T3.t(3),'o','color','r','LineWidth',2);

% robot.plot(q*rad2deg,'tilesize',0.150,'workspace',W,'trail',{'r','LineWidth',3});

robot.model3d = 'ROCR6/MDH_stl';

robot.plot3d(deg2rad(q),'workspace',W,'movie','JointSpace.gif', ...

           'view',[24 30],'trail',{'r','LineWidth',3.5}) %顯示三維動畫

Animate: saving video --> JointSpace.gif with profile 'GIF'

Loading STL models from ARTE Robotics Toolbox for Education  by Arturo Gil (http://arvc.umh.es/arte).......

light('Position', [1 0.5 1]);

六自由度機械臂五次多項式軌跡規劃(Fivejtraj_Function自編寫函數)的圖1

%% 繪制曲線圖

figure('Color',[1,1,1],'Position',[485,180,536,325]);

for i=1:n

plot(SimpleNum,qT(i,1:Cunt),'LineWidth',2);hold on;

end

string='關節角度(deg)';

xlabel('t(s)'),ylabel(string,'Interpreter','tex','FontSize',10);grid on;

legend1 = legend('joint1 ','joint2','joint3','joint4','joint5','joint6');

set(legend1,...

   'Position',[0.06 0.94 0.89 0.06],...

   'Orientation','horizontal');

六自由度機械臂五次多項式軌跡規劃(Fivejtraj_Function自編寫函數)的圖2

%%

figure('Color',[1,1,1],'Position',[485,180,536,325]);

for i=1:n

plot(SimpleNum,vT(i,1:Cunt),'LineWidth',2);hold on;

end

string='關節角速度(deg/s)';

xlabel('t(s)'),ylabel(string,'Interpreter','tex','FontSize',10);grid on;

legend('joint1 ','joint2','joint3','joint4','joint5','joint6');

六自由度機械臂五次多項式軌跡規劃(Fivejtraj_Function自編寫函數)的圖3

%%

figure('Color',[1,1,1],'Position',[485,180,536,325]);

for i=1:n

plot(SimpleNum,aT(i,1:Cunt),'LineWidth',2);hold on;

end

string='關節角加速度(deg/s^2)';

xlabel('t(s)'),ylabel(string,'Interpreter','tex','FontSize',10);grid on;

legend('joint1 ','joint2','joint3','joint4','joint5','joint6');

六自由度機械臂五次多項式軌跡規劃(Fivejtraj_Function自編寫函數)的圖4

源文件下載鏈接

40`}%$BLNAOV`XG6`0PN`QX.png

需要技術服務聯系qq2386317960

以下內容為付費內容,請購買后觀看

六自由度機械臂五次 三次多項式軌跡規劃(自編多項式寫函數)

App下載
技術鄰APP
工程師必備
  • 項目客服
  • 培訓客服
  • 平臺客服

TOP

2