• IMPALA67
    了解作者
  • matlab
    开发工具
  • 21KB
    文件大小
  • rar
    文件格式
  • 2
    收藏次数
  • 10 积分
    下载积分
  • 16
    下载次数
  • 2019-05-04 03:12
    上传日期
基于matlab的二连杆机械臂的滑模控制
滑模控制.rar
  • untitled.mdl
    42.3KB
  • untitled.mdl.r2010a
    39.1KB
  • hm_plot.m
    814B
  • fal.m
    1KB
  • object.m
    1.3KB
  • geiding.m
    5KB
  • geiding.asv
    2.5KB
内容介绍
function [sys,x0,str,ts] = spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts]=mdlInitializeSizes; case 1, sys=mdlDerivatives(t,x,u); case 3, sys=mdlOutputs(t,x,u); case {2,4,9} sys=[]; otherwise error(['Unhandled flag = ',num2str(flag)]); end function [sys,x0,str,ts]=mdlInitializeSizes sizes = simsizes; sizes.NumContStates = 0; sizes.NumDiscStates = 0; sizes.NumOutputs = 4; sizes.NumInputs = 0; sizes.DirFeedthrough = 0; sizes.NumSampleTimes = 1; sys = simsizes(sizes); x0 = []; str = []; ts = [0 0]; function sys=mdlOutputs(t,x,u) l1=3;l2=3; % q1=0.5*sin(pi*t); % q2=sin(pi*t); % xd=-l1*sin(q1)-l2*sin(q1+q2); % % yd=l1*cos(q1)+l2*cos(q1+q2); % if (rem(t,20)<=5) % xd=0.1*rem(t,20)+4.0; % yd=2.5; % elseif((rem(t,20)>5)&&(rem(t,20)<=10)) % xd=4.5; % yd=2+0.1*rem(t,20); % elseif((rem(t,20)>10)&&(rem(t,20)<=15)) % xd=5.5-0.1*rem(t,20); % yd=3.0; % elseif((rem(t,20)>15)&&(rem(t,20)<=20)) % xd=4.0; % yd=4.5-0.1*rem(t,20); % else % xd=4.0; % yd=2.5; % end T=20 if (rem(t,30)<=7.5) xd=1/15*rem(t,30)+4.0; yd=2.5; elseif((rem(t,30)>7.5)&&(rem(t,30)<=15)) xd=4.5; yd=2+1/15*rem(t,30); elseif((rem(t,30)>15)&&(rem(t,30)<=22.5)) xd=5.5-1/15*rem(t,30); yd=3.0; elseif((rem(t,30)>22.5)&&(rem(t,30)<=30)) xd=4.0; yd=4.5-1/15*rem(t,30); else xd=4.0; yd=2.5; end % if (rem(t,15)<=3.75) % xd=2/15*rem(t,15)+4.0; % yd=2.5; % elseif((rem(t,15)>3.75)&&(rem(t,15)<=7.5)) % xd=4.5; % yd=2+2/15*rem(t,15); % elseif((rem(t,15)>7.5)&&(rem(t,15)<=11.25)) % xd=5.5-2/15*rem(t,15); % yd=3.0; % elseif((rem(t,15)>11.25)&&(rem(t,15)<=15)) % xd=4.0; % yd=4.5-2/15*rem(t,15); % else % xd=4.0; % yd=2.5; % end T=15 % if (rem(t,12)<=3) % xd=2/12*rem(t,12)+4.0; % yd=2.5; % elseif((rem(t,12)>3)&&(rem(t,12)<=6)) % xd=4.5; % yd=2+2/12*rem(t,12); % elseif((rem(t,12)>6)&&(rem(t,12)<=9)) % xd=5.5-2/12*rem(t,12); % yd=3.0; % elseif((rem(t,12)>9)&&(rem(t,12)<=12)) % xd=4.0; % yd=4.5-2/12*rem(t,12); % else % xd=4.0; % yd=2.5; % end T=12 % if (rem(t,6)<=1.5) % xd=2/6*rem(t,6)+4.0; % yd=2.5; % elseif((rem(t,6)>1.5)&&(rem(t,6)<=3)) % xd=4.5; % yd=2+2/6*rem(t,6); % elseif((rem(t,6)>3)&&(rem(t,6)<=4.5)) % xd=5.5-2/6*rem(t,6); % yd=3.0; % elseif((rem(t,6)>4.5)&&(rem(t,6)<=6)) % xd=4.0; % yd=4.5-2/6*rem(t,6); % else % xd=4.0; % yd=2.5; % end T=6 % if (rem(t,1)<=0.25) % xd=2/1*rem(t,1)+4.0; % yd=2.5; % elseif((rem(t,1)>0.25)&&(rem(t,1)<=0.5)) % xd=4.5; % yd=2+2/1*rem(t,1); % elseif((rem(t,1)>0.5)&&(rem(t,1)<=0.75)) % xd=5.5-2/1*rem(t,1); % yd=3.0; % elseif((rem(t,1)>0.75)&&(rem(t,1)<=1)) % xd=4.0; % yd=4.5-2/1*rem(t,1); % else % xd=4.0; % yd=2.5; % end T=1 % if (rem(t,0.5)<=0.125) % xd=2/0.5*rem(t,0.5)+4.0; % yd=2.5; % elseif((rem(t,0.5)>0.125)&&(rem(t,0.5)<=0.25)) % xd=4.5; % yd=2+2/0.5*rem(t,0.5); % elseif((rem(t,0.5)>0.25)&&(rem(t,0.5)<=0.375)) % xd=5.5-2/0.5*rem(t,0.5); % yd=3.0; % elseif((rem(t,0.5)>0.375)&&(rem(t,0.5)<=0.5)) % xd=4.0; % yd=4.5-2/0.5*rem(t,0.5); % else % xd=4.0; % yd=2.5; % end T=0.5 % if (rem(t,60)<=15) % xd=2/60*rem(t,60)+4.0; % yd=2.5; % elseif((rem(t,60)>15)&&(rem(t,60)<=30)) % xd=4.5; % yd=2+2/60*rem(t,60); % elseif((rem(t,60)>30)&&(rem(t,60)<=45)) % xd=5.5-2/60*rem(t,60); % yd=3.0; % elseif((rem(t,60)>45)&&(rem(t,60)<=60)) % xd=4.0; % yd=4.5-2/60*rem(t,60); % else % xd=4.0; % yd=2.5; % end T=60 % if (rem(t,300)<=75) % xd=2/300*rem(t,300)+4.0; % yd=2.5; % elseif((rem(t,300)>75)&&(rem(t,300)<=150)) % xd=4.5; % yd=2+2/300*rem(t,300); % elseif((rem(t,300)>150)&&(rem(t,300)<=225)) % xd=5.5-2/300*rem(t,300); % yd=3.0; % elseif((rem(t,300)>225)&&(rem(t,300)<=300)) % xd=4.0; % yd=4.5-2/300*rem(t,300); % else % xd=4.0; % yd=2.5; % end T=300 % if (rem(t,600)<=150) % xd=2/600*rem(t,600)+4.0; % yd=2.5; % elseif((rem(t,600)>150)&&(rem(t,600)<=300)) % xd=4.5; % yd=2+2/600*rem(t,600); % elseif((rem(t,600)>300)&&(rem(t,600)<=450)) % xd=5.5-2/600*rem(t,600); % yd=3.0; % elseif((rem(t,600)>450)&&(rem(t,600)<=600)) % xd=4.0; % yd=4.5-2/600*rem(t,600); % else % xd=4.0; % yd=2.5; % end qd2=-acos((xd^2+yd^2-(l1^2+l2^2))/(2*l1*l2)); if(yd>=0) alfa_0=atan(xd/yd); else alfa_0=pi+atan(xd/yd); end beta_0=acos((xd^2+yd^2+l1^2-l2^2)/(2*l1*sqrt(xd^2+yd^2))); qd1=beta_0-alfa_0; sys(1)=qd1; sys(2)=qd2; sys(3)=xd; sys(4)=yd;
评论
    相关推荐