资源描述:
《设计九基于模糊推理自主移动机器人避障控制》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、附录设计过程和程序清单参考程序如下:function[x,y]=obstacleavoidance(T1,N1,T2,N2,T3,N3,X0,Y0,XG,YG,STEP)holdonx(1)=X0;y(1)=Y0;t1=pi/4;t2=pi/2;t3=3*pi/4;theta=0;n=1;if((N3==0)&&((N1+N2)==0))error%只有A类障碍物的情况elseif((N3==0)&&((N1+N2)~=0))while(((x(n)-XG)^2+(y(n)-YG)^2)>STEP^2)dr=mindetected((t1-t
2、heta),T1,N1,T2,N2,x(n),y(n));dc=mindetected((t2-theta),T1,N1,T2,N2,x(n),y(n));dl=mindetected((t3-theta),T1,N1,T2,N2,x(n),y(n));tg=atan((XG-x(n))+i*(YG-y(n)))*180/pi-theta;sa=fuzzylogic(dr,dc,dl,tg);step=STER*(1-abs(sa)/100);sa=sa*pi/180;x(n+1)=x(n)+step*sin(sa);y(n+1)=y(n)+
3、step*cos(sa);theta=theta+sa;n=n+1;end%只有B类障碍物的情况elseif(((N1+N2)==0)&&(N3~=0))while(((x(n)-XG)^2+(y(n)-YG)^2)>STEP^2)dr=mindetectedquare((t1-theta),T3,N3,x(n),y(n));dc=mindetectedquare((t2-theta),T3,N3,x(n),y(n));dl=mindetectedquare((t3-theta),T3,N3,x(n),y(n));tg=atan((XG-x(
4、n))+i*(YG-y(n)))*180/pi-theta;sa=fuzzylogic(dr,dc,dl,tg);step=STER*(1-abs(sa)/100);sa=sa*pi/180;x(n+1)=x(n)+step*sin(sa);y(n+1)=y(n)+step*cos(sa);theta=theta+sa;n=n+1;end%A、B类障碍物都有的情况elsewhile(((x(n)-XG)^2+(y(n)-YG)^2)>STEP^2)dr1=mindetected((t1-theta),T1,N1,T2,N2,x(n),y(n)
5、);dr2=mindetectedquare((t1-theta),T3,N3,x(n),y(n));dc1=mindetected((t2-theta),T1,N1,T2,N2,x(n),y(n));dc2=mindetectedquare((t2-theta),T3,N3,x(n),y(n));dl1=mindetected((t3-theta),T1,N1,T2,N2,x(n),y(n));dl2=mindetectedquare((t3-theta),T3,N3,x(n),y(n));dr=min(dr1,dr2);dc=min(dc
6、1,dc2);dl=min(dl1,dl2);tg=atan((XG-x(n))+i*(YG-y(n)))*180/pi-theta;sa=fuzzylogic(dr,dc,dl,tg);step=STER*(1-abs(sa)/100);sa=sa*pi/180;x(n+1)=x(n)+step*sin(sa);y(n+1)=y(n)+step*cos(sa);theta=theta+sa;n=n+1;endend%距离传感器的模拟functiondmin=mindetected(a,T1,N1,T2,N2,x,y)dmin1=mindet
7、ected1(a,T1,N1,x,y);dmin2=mindetected2(a,T2,N2,x,y);endfunctiondmin1=mindetected1(a,T,N,x,y)if(N==0)dmin1=100000;elsed(1)=detectedline1(a,T(1,1),T(1,2),x,y,T(1,3),T(1,4));dmin1=d(1);j=1;fori=2:Nd(i)=detectedline1(a,T(i,1),T(i,2),x,y,T(i,3),T(i,4));if(d(i)8、j);endendendfunctiont=detectedline1(a,b,k,x,y,minx,maxx)if(tan(a)~=k)t=(b+k*x-y)/(