1 简介
移动机器人路径规划一直是一个比较热门的话题,A星算法以及其扩展性算法被广范地应用于求解移动机器人的最优路径.该文在研究机器人路径规划算法中,详细阐述了传统A星算法的基本原理,并通过栅格法分割了机器人路径规划区域,利用MATLAB仿真平台生成了机器人二维路径仿真地图对其进行仿真实验,并对结果进行分析和研究,为今后进一步的研究提供经验.
1.1 A星算法
1.2 曼哈顿距离
1.3 具体原理
1.4 流程图
2 部分代码
function i_min = min_fn(OPEN,OPEN_COUNT,xTarget,yTarget)
%Function to return the Node with minimum fn
% This function takes the list OPEN as its input and returns the index of the
% node that has the least cost
%
% Copyright 2009-2010 The MathWorks, Inc.
temp_array=[];
k=1;
flag=0;
goal_index=0;
for j=1:OPEN_COUNT
if (OPEN(j,1)==1)
temp_array(k,:)=[OPEN(j,:) j]; %#ok<*AGROW>
if (OPEN(j,2)==xTarget && OPEN(j,3)==yTarget)
flag=1;
goal_index=j; %Store the index of the goal node 存储目标节点的索引
end;
k=k+1;
end;
end; %Get all nodes that are on the list open 获取列表中的所有节点
if flag == 1 % one of the successors is the goal node so send this node 其中一个后继者是目标节点,因此发送此节点
i_min=goal_index;
end
%Send the index of the smallest node 发送最小节点的索引
if size(temp_array ~= 0)
% temp_array %%%****输出temp_array,用来学习了解A*算法的运算过程**** ///不需要知道过程可注释掉///
[min_fn,temp_min]=min(temp_array(:,8));%Index of the smallest node in temp array 临时数组中最小节点的索引
%%%最小值赋给min_fn,最小值所在的行数赋给temp_min; 比如 A=[1 2 3;4 5 6;7 8 9;0 0 0] [a,b]=min(A(:,3)) a=0 b=4;
i_min=temp_array(temp_min,9); %Index of the smallest node in the OPEN array OPEN数组中最小节点的索引
else
i_min=-1;%The temp_array is empty i.e No more paths are available. temp_array是空的,即没有更多的路径可用
end;
3 仿真结果
4 参考文献
[1]姜立标, 洪顺. 一种基于改进A星算法的智能车全局路径规划方法:, CN111982142A[P]. 2020.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
完整代码获取关注微信公众号天天matlab