【路径规划】智能仓储中基于A*算法的多AGV路径规划研究matlab代码

563 阅读4分钟

1 简介

对于自动导引车(Automated Guided Vehicle,AGV)的单机路径规划问题,已存在很多静态算法可以有效求解。但由于 AGV间抢占系统资源的相互影响和制约,多 AGV的协同作业会出现死锁、碰撞冲突等问题,静态路径规划算法无法满足实时动态作业的系统需求。智能仓储系统中,多AGV动态路径规划的核心问题不再仅是单AGV快速求解最优路径,而在于多AGV的冲突避免或解决,达到整体协调最优。拟采用两种思路解决上诉问题:一种方案是对最有效的静态算法进行改进,并引入动态机制和冲突解决策略以满足作业需求;另一种方案提出一种具备多步前瞻性的主动避障算法,优化路径并提前避开交通拥堵路段,减少冲突可能性和重新寻路代价。实验结果表明两种算法都具有良好的鲁棒性,可有效解决冲突,且后者可持续扩展AGV数量,具有更高的系统效率。​

对于静态路网路径规划问题,全局信息已知,站位及障碍信息不随时间变化,单AGV进行路径规划时,不存在其他 AGV 干扰,可以较好地获得理论最优路径。而对于多 AGV 的动态路网路径规划问题,地图信息动态变化,多 AGV 间相互影响,很难获得系统全局信息。A*算法是一种静态路网中求解最短路最有效的方法,存在应用价值及意义,但是它却不能有效解决多 AGV的动态路径规划问题,因此有必要对其进行改进。同时本文提出一种具备多步预测功能的主动式寻路算法,将其与 A*算法的改进算法比较,在有效解决冲突的基础上,验证新算法的可靠性和优异性。

2 部分代码

%main函数,robot_number的数目目前支持2~6clear all;
close all;
clear variables;
clc;
robot_number=3;
[map,grid1,Nrow,Ncol,sorting_table,Obstacle]=initial_input();
% Obstacle_index=max(round(rand(1,30)*length(Obstacle)),1);
%   Obstacle_index=randperm(length(Obstacle),10);
  Obstacle_index=[48,24,70,43,34,15,59,12,58,35,46,61, 4,79,30,63,60,31,67,37, 6,20,50,73,72,56,47,14,78,62];
mission_list=[];start_node=[];
for i=1:length(Obstacle_index)
 mission_list=[mission_list,Obstacle(Obstacle_index(i))];
end
mission=mission_list(1:robot_number);
%从N个数中不重复的选取一些数
%   start_node=Obstacle(randperm(length(Obstacle),robot_number));
  start_node=[166,352,5,12,120,220,240,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40];
for k1=1:robot_number    
   robot_ID(k1)=robot();
   robot_ID(k1).location=start_node(k1);
end

[scedule_table,undistributed_mission]=Schedule1(robot_ID,mission,Nrow,Ncol);
%scedule_table结果的第一行为任务的索引,格式大多数情况为1:length(mission), 第二行为该任务分配给的小车。
for i=1:length(scedule_table(1,:))
   end_node(scedule_table(2,i))=mission(scedule_table(1,i));
end
for k2=1:robot_number
   map3=map;
   for map_i = 1:robot_number
       if map_i~=k2
          [ia,ib]=ind2sub([Nrow,Ncol],start_node(map_i));
           map3(Ncol-ib+1,ia)=2;
          [ia1,ib1]=ind2sub([Nrow,Ncol],end_node(map_i));
           map3(Ncol-ib1+1,ia1)=2;
       end
   end
  [sorting_table_index]assign_sorting_table(end_node(k2),sorting_table);
   allpath_ID(k2)=allpath([Astar_method(start_node(k2),end_node(k2),0,map3),Astar_method(end_node(k2),sorting_table(sorting_table_index,1),1,map3),...
   sorting_table(sorting_table_index,2:4),Astar_method(sorting_table(sorting_table_index,5),end_node(k2),1,map3)]);
end

if length(robot_ID)>1
   % 所有的两两路径冲突检验
   all_conflict=nchoosek(1:length(robot_ID), 2);
   k1=1;iters=length(all_conflict(:,1))*2;
   while k1<=length(all_conflict(:,1))&iters>0;
       if k1==1
          [wait_path1,wait_path2,result1]=Enqueue1(allpath_ID(all_conflict(k1,1)).wait_path,...
               allpath_ID(all_conflict(k1,2)).wait_path,1,map);
          [wait_path4,wait_path3,result2]=Enqueue1(allpath_ID(all_conflict(k1,2)).wait_path,...
               allpath_ID(all_conflict(k1,1)).wait_path,1,map);
           if (result1==11)&(result2==11)
               disp('前两量车无法避让,需要重新规划路径')
           else
               if (result2==11)|((result1==10)&(length(wait_path1)+length(wait_path2)<=length(wait_path3)+length(wait_path4)))
                   allpath_ID(all_conflict(k1,1)).wait_path=wait_path1;
                   allpath_ID(all_conflict(k1,2)).wait_path=wait_path2;
               else
                   allpath_ID(all_conflict(k1,1)).wait_path=wait_path3;
                   allpath_ID(all_conflict(k1,2)).wait_path=wait_path4;
               end
           end
           k1=k1+1;
       else
          [wait_path5,wait_path6,result3]=Enqueue1(allpath_ID(all_conflict(k1,1)).wait_path,...
               allpath_ID(all_conflict(k1,2)).wait_path,1,map,sorting_table);
           if result3==10
               allpath_ID(all_conflict(k1,1)).wait_path=wait_path5;
               allpath_ID(all_conflict(k1,2)).wait_path=wait_path6;
               k1=k1+1;
           else 
              [wait_path6,wait_path5,result3]=Enqueue1(allpath_ID(all_conflict(k1,2)).wait_path,...
               allpath_ID(all_conflict(k1,2)).wait_path,1,map);
               if result3==10
                   allpath_ID(all_conflict(k1,1)).wait_path=wait_path5;
                   allpath_ID(all_conflict(k1,2)).wait_path=wait_path6;
                   k1=1;
               else
                   if result3==12
                       allpath_ID(all_conflict(k1,1)).wait_path=wait_path5;
                       allpath_ID(all_conflict(k1,2)).wait_path=wait_path6;
                       k1=1;
%                     disp('某两量车无法避让,需要重新规划路径')
                   end
               end
           end
       end
       iters=iters-1;
       if iters==0;
           disp('超出最大迭代次数,需要重新规划路径')
       end
   end
   %初始化小车
   for k3=1:robot_number
       robot_ID(k3)=robot(allpath_ID(k3).wait_path,Nrow,0,0);
       robot_ID(k3).location=start_node(k3);robot_ID(k3).loading_state=1;
   end
   for i=1:length(scedule_table(1,:))
       robot_ID(scedule_table(2,i)).next_mission=mission(scedule_table(1,i));
   end
   
else
   robot_ID(1)=robot(allpath_ID(1).wait_path,Nrow,0,0);
   robot_ID(1).location=start_node(1);robot_ID(1).loading_state=1;
   robot_ID(scedule_table(2,1)).next_mission=mission(scedule_table(1,1));
end


% 仿真演示
% diary('log_07.txt')
result=draw_map(map,grid1,robot_ID,Nrow,Ncol,mission_list,sorting_table)

3 仿真结果

4 参考文献

[1]穆涛, and 郭学平. "智能仓储中基于A*算法的多AGV路径规划研究." 福建质量管理. 

部分理论引用网络文献,若有侵权联系博主删除。

5 MATLAB代码与数据下载地址

见博客主页