资源简介
用 MATLAB 实现基于栅格地图的A-星算法路径规划,代码中障碍物是随机的。

代码片段和文件信息
function shangeaxingdaima
%ASTARDEMO Demonstration of ASTAR algorithm
n = 20; % field size n x n tiles 20*20的界面
wallpercent = 0.35; % this percent of field is walls 35%的界面作为阻碍物(墙)
% create the n x n FIELD with wallpercent walls containing movement costs 创建包含移动成本的wallpercent墙
% a starting position STARTPOSIND a goal position GOALPOSIND the costs 起始位置startposind 目标位置goalposind成本
% A star will compute movement cost for each tile COSTCHART 星号将计算每个方格的移动开销
% and a matrix in which to store the pointers FIELDPOINTERS 存储指针fieldpointers的矩阵
[field startposind goalposind costchart fieldpointers] = ...
initializeField(nwallpercent); %初始化界面
% initialize the OPEN and CLOSED sets and their costs ,初始化开集和闭集及其代价
setOpen = startposind; setOpenCosts = 0; setOpenHeuristics = Inf; %Heuristics 启发式
setClosed = []; setClosedCosts = [];
movementdirections = {‘R‘‘L‘‘D‘‘U‘};
% keep track of the number of iterations to exit gracefully if no solution counterIterations = 1;如果没有解决方案counteriterations = 1 请跟踪要正常退出的迭代次数;
axishandle = createFigure(fieldcostchartstartposindgoalposind);
% as long as we have not found the goal or run out of spaces to explore 只要我们没有找到目标或跑出空间去探索
while ~max(ismember(setOpengoalposind)) && ~isempty(setOpen) %ismember(AB)返回与A同大小的矩阵,其中元素1表示A中相应位置的元素在B中也出现,0则是没有出现
% for the element in OPEN with the smallest cost
[tempii] = min(setOpenCosts + setOpenHeuristics); %从OPEN表中选择花费最低的点tempii是其下标(也就是标号索引) temp改为~
% find costs and heuristic of moving to neighbor spaces to goal
% in order ‘R‘‘L‘‘D‘‘U‘
[costsheuristicsposinds] = findFValue(setOpen(ii)setOpenCosts(ii) ...
fieldgoalposind‘euclidean‘); %扩展temp的四个方向点,获得其坐标posinds,各个方向点的实际代价costs,启发代价heuristics
% put node in CLOSED and record its cost
setClosed = [setClosed; setOpen(ii)]; %将temp插入CLOSE表中
setClosedCosts = [setClosedCosts; setOpenCosts(ii)]; %将temp的花费计入ClosedCosts
% update OPEN and their associated costs 更新OPEN表 分为三种情况
if (ii > 1 && ii < length(setOpen)) %temp在OPEN表的中间,删除temp
setOpen = [setOpen(1:ii-1); setOpen(ii+1:end)];
setOpenCosts = [setOpenCosts(1:ii-1); setOpenCosts(ii+1:end)];
setOpenHeuristics = [setOpenHeuristics(1:ii-1); setOpenHeuristics(ii+1:end)];
elseif (ii == 1)
setOpen = setOpen(2:end); %temp是OPEN表的第一个元素,删除temp
setOpenCosts = setOpenCosts(2:end);
setOpenHeuristics = setOpenHeuristics(2:end);
else %temp是OPEN表的最后一个元素,删除temp
setOpen = setOpen(1:end-1);
setOpenCosts = setOpenCosts(1:end-1);
setOpenHeuristics = setOpenHeuristics(1:end-1);
end
% for each of these neighbor spaces assign costs and pointers; 对于每个邻居空间分配成本和指针;
% and if some are in the CLOSED set and their costs are smaller 如果一些是在封闭集合他们的成本较小
% update their costs and pointers 更新他们的成本和指针
for jj=1:length(posinds) %对于扩展的四个方向的坐标
% if cost infinite then it‘s a wall so ignore 如果成本无限那么它就是一堵墙所以忽略
if ~isinf(costs(jj)) %如果此点的实际代价不为Inf(无穷)也就是没有遇到墙
% if node is not in OPEN or CLOSED then insert into costcha
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-19 09:28 A星代码(任意)+文档\
文件 372 2007-01-07 13:57 A星代码(任意)+文档\A.caa
文件 372 2007-01-07 13:59 A星代码(任意)+文档\A1.caa
文件 280122 2007-01-07 13:58 A星代码(任意)+文档\A_算法在矢量地图最优路径搜索中的应用_刘浩 (1).caj
文件 280122 2007-01-07 13:58 A星代码(任意)+文档\A_算法在矢量地图最优路径搜索中的应用_刘浩.caj
文件 244875 2007-01-07 13:59 A星代码(任意)+文档\A_算法改进算法及其应用_张仁平.caj
目录 0 2018-01-19 09:28 A星代码(任意)+文档\A星算法障碍任意\
文件 15167 2017-04-26 20:31 A星代码(任意)+文档\A星算法障碍任意\shangeaxingdaima.m
文件 231797 2007-01-07 13:59 A星代码(任意)+文档\基于加权A_算法的服务型机器人路径规划_赵真明.caj
文件 686043 2007-01-07 13:58 A星代码(任意)+文档\基于平滑A_算法的移动机器人路径规划_王红卫.caj
- 上一篇:基于栅格地图的A星算法路径规划
- 下一篇:matlab反距离权重插值
相关资源
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
评论
共有 条评论