资源简介
A星算法实现路径规划,可以直接运行代码。随机生成起点和终点,采用A*算法实现最短路径,同时有绘图展现最终结果。
代码片段和文件信息
function astardemo
%ASTARDEMO Demonstration of ASTAR algorithm
%
% Copyright Bob L. Sturm Ph. D. Assistant Professor
% Department of Architecture Design and Media Technology
% formerly Medialogy
% Aalborg University i Ballerup
% formerly Aalborg University Copenhagen
% $Revision: 0.1 $ $Date: 2011 Jan. 15 18h24:24$
n = 20; % field size n x n tiles
wallpercent = 0.45; % this percent of field is walls
% create the n x n FIELD with wallpercent walls containing movement costs
% a starting position STARTPOSIND a goal position GOALPOSIND the costs
% A star will compute movement cost for each tile COSTCHART
% and a matrix in which to store the pointers FIELDPOINTERS
[field startposind goalposind costchart fieldpointers] = ...
initializeField(nwallpercent);
% initialize the OPEN and CLOSED sets and their costs
setOpen = [startposind]; setOpenCosts = [0]; setOpenHeuristics = [Inf];
setClosed = []; setClosedCosts = [];
movementdirections = {‘R‘‘L‘‘D‘‘U‘};
% keep track of the number of iterations to exit gracefully if no solution
counterIterations = 1;
% create figure so we can witness the magic
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)
% for the element in OPEN with the smallest cost
[temp ii] = min(setOpenCosts + setOpenHeuristics);
% 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‘);
% put node in CLOSED and record its cost
setClosed = [setClosed; setOpen(ii)];
setClosedCosts = [setClosedCosts; setOpenCosts(ii)];
% update OPEN and their associated costs
if (ii > 1 && ii < length(setOpen))
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);
setOpenCosts = setOpenCosts(2:end);
setOpenHeuristics = setOpenHeuristics(2:end);
else
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))
% if node is not in OPEN or CLOSED then insert into costchart and
% movement pointers and put node in OPEN
if ~max([setClosed; setOpen] == posinds(jj))
fieldpointers(posinds(jj)) = movementdirections(jj);
costchart(posinds(jj)) = costs(jj);
setOpen = [setOpen; posinds(jj)];
setOpenCosts = [setOpenCosts; costs(jj)]
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-07-05 13:33 A-star-master\
目录 0 2018-07-05 13:33 A-star-master\C++\
目录 0 2018-07-05 13:33 A-star-master\C++\Astar\
文件 939 2018-07-05 13:33 A-star-master\C++\Astar\Astar.sln
文件 27136 2018-07-05 13:33 A-star-master\C++\Astar\Astar.v12.suo
目录 0 2018-07-05 13:33 A-star-master\C++\Astar\Astar\
文件 5754 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Astar.cpp
文件 4435 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Astar.vcxproj
文件 1277 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Astar.vcxproj.filters
目录 0 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\
文件 2041 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.log
文件 339332 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.obj
文件 2031616 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.pch
目录 0 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.tlog\
文件 176 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.tlog\Astar.lastbuildstate
文件 16406 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.tlog\CL.read.1.tlog
文件 2490 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.tlog\CL.write.1.tlog
文件 3034 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.tlog\cl.command.1.tlog
文件 2786 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.tlog\li
文件 5688 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.tlog\li
文件 1334 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\Astar.tlog\li
文件 11205 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\stdafx.obj
文件 363520 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\vc120.idb
文件 430080 2018-07-05 13:33 A-star-master\C++\Astar\Astar\Debug\vc120.pdb
文件 1466 2018-07-05 13:33 A-star-master\C++\Astar\Astar\ReadMe.txt
文件 203 2018-07-05 13:33 A-star-master\C++\Astar\Astar\stdafx.cpp
文件 219 2018-07-05 13:33 A-star-master\C++\Astar\Astar\stdafx.h
文件 228 2018-07-05 13:33 A-star-master\C++\Astar\Astar\targetver.h
目录 0 2018-07-05 13:33 A-star-master\C++\Astar\Debug\
文件 104960 2018-07-05 13:33 A-star-master\C++\Astar\Debug\Astar.exe
文件 453500 2018-07-05 13:33 A-star-master\C++\Astar\Debug\Astar.ilk
............此处省略7个文件信息
- 上一篇:SARscape5.2哨兵数据处理流程
- 下一篇:品优购项目源码
相关资源
- 细化算法及其在路径规划应用
- A*算法解决旅行商问题
- 基于遗传算法启发式算法退火算法的
- 水面无人艇局部危险避障算法研究 答
-
me
taheuristics From Design to Implementatio - cpp-CppRoboticscpp实现机器人算法包括定
- 蚁群算法在机器人路径规划中的应用
- 室内清洁机器人的全区域路径规划及
- 清洁机器人系统开发及路径规划研究
- 简易智能车\\智能小车的避障及路径规
- 完整项目开发文档--物流配送最优路径
- 车辆导航系统中大区域路径规划算法
- 基于改进人工蜂群算法的机器人路径
- 基于人工势场法的移动机器人动态路
- 高级排产计划中启发式算法研究与实
- 百度地图定位和路径规划
- ROS机器人turtlebot路径规划
- 六自由度机械臂避障路径规划研究
- 配送车辆优化调度模型与算法
- 无人驾驶汽车的路径规划与跟随控制
- 基于高德的路径规划
- 产品战略与路径规划
- 启发式算法
- slam避障/建图/导航/视觉定位/3Dslam 5篇
- 经典路径规划书籍
- 基于蚁群算法的二维路径规划算法5
- A*算法旅行商问题实验报告和代码
- 基于蚁群算法的三维路径规划算法
- 机械臂避障路径规划仿真 路径平滑
- 机械臂碰撞检测 八组逆解碰撞检测
评论
共有 条评论