【路径规划】基于A星算法求解自定义起点终点障碍路径规划问题matlab代码

127 阅读1分钟

1 简介

移动机器人路径规划一直是一个比较热门的话题,A星算法以及其扩展性算法被广范地应用于求解移动机器人的最优路径.该文在研究机器人路径规划算法中,详细阐述了传统A星算法的基本原理,并通过栅格法分割了机器人路径规划区域,利用MATLAB仿真平台生成了机器人二维路径仿真地图对其进行仿真实验,并对结果进行分析和研究,为今后进一步的研究提供经验.

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)
[min_fn,temp_min]=min(temp_array(:,8));%Index of the smallest node in temp array
 i_min=temp_array(temp_min,9);%Index of the smallest node in the OPEN array
else
    i_min=-1;%The temp_array is empty i.e No more paths are available.
end;

3 仿真结果

4 参考文献

[1]周宇杭等. "基于A星算法的移动机器人路径规划应用研究." 电脑知识与技术 v.16.13(2020):7-9+16.

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

5 MATLAB代码与数据下载地址

见博客主页