資源簡介
通過matlab的GUI編程實現單個機器人的多任務路徑規劃,測試可運行。

代碼片段和文件信息
function?ASTAR2(handlesmap2startposindgoalposind)
?n?=?11;???%?field?size?n?x?n?tiles??20*20的界面
%wallpercent?=?0.3;??%?this?percent?of?field?is?walls???15%的界面作為阻礙物(墻)
cmap?=?[1?1?1;?...%??1?-?white?-?空地
????????0?0?0;?...%?2?-?black?-?障礙?
????????1?0?0;?...%?3?-?red?-?已搜索過的地方
????????0?0?1;?...%?4?-?blue?-?下次搜索備選中心?
????????0?1?0;?...%?5?-?green?-?起始點
????????1?1?0;...%?6?-?yellow?-??到目?標點的路徑?
???????1?0?1];%?7?-?-??目標點?
colormap(cmap);?
?field?=?map2;
%startposind?=12;???%sub2ind用來將行列坐標轉換為線性坐標,這里是必要的,因為如果把startposind設置成[xy]的形式,訪問field([xy])的時候
%goalposind?=82;????%它并不是訪問x行y列元素,而是訪問線性坐標為x和y的兩個元素
%?field(ceil(n^2.*rand(floor(n*n*wallpercent)1)?))?=?Inf;
%?startposind?=?sub2ind([nn]ceil(n.*rand)ceil(n.*rand));???%sub2ind用來將行列坐標轉換為線性坐標,這里是必要的,因為如果把startposind設置成[xy]的形式,訪問field([xy])的時候
%goalposind?=?sub2ind([nn]ceil(n.*rand)ceil(n.*rand));????%它并不是訪問x行y列元素,而是訪問線性坐標為x和y的兩個元素
%?put?not?a?numbers?(NaN)?in?cost?chart?so?A*?knows?where?to?look
costchart?=?NaN*ones(n);??????%costchart用來存儲各個點的實際代價,NaN代表不是數據(不明確的操作)
%?set?the?cost?at?the?starting?position?to?be?0
costchart(startposind)?=?0;?????%起點的實際代價
%?make?fieldpointers?as?a?cell?array??生成n*n的元胞
fieldpointers?=?cell(n);??????%fieldpointers用來存儲各個點的來源方向
%?set?the?start?pointer?to?be?“S“?for?start?“G“?for?goal???起點設置為“S“終點設置為“G“
%?everywhere?there?is?a?wall?put?a?0?so?it?is?not?considered???墻設置為0
fieldpointers(field?==?2)?=?{0};??????%很好的方式,field?==?Inf?返回墻的位置,fieldpointers(field?==?Inf)設置相應的位置
%?field(field?==?Inf)=2;
fieldpointers{startposind}?=?‘S‘;?fieldpointers{goalposind}?=?‘G‘;
setOpen?=?(startposind);?setOpenCosts?=?(0);?setOpenHeuristics?=?(Inf);
setClosed?=?[];?setClosedCosts?=?[];%初始化起點的open表和close表
%?setOpen1?=?(goalposind);?setOpenCosts1?=?(0);?setOpenHeuristics1?=?(Inf);
%?setClosed1?=?[];?setClosedCosts1?=?[];%初始化目標點的open表和close表
movementdirections?=?{‘L‘‘R‘‘U‘‘D‘};
%movementdirections1?=?{‘LU‘‘RU‘‘LD‘‘RD‘};
%?keep?track?of?the?number?of?iterations?to?exit?gracefully?if?no?solution
counterIterations?=?1;
%%?create?figure?so?we?can?witness?the?magic
?%?n?=?length(field);
?????%?plot?goal?as?a?yellow?square?and?start?as?a?green
?????%?circle把目標點畫成紫色,起始點為綠色
%??????[goalposygoalposx]?=?ind2sub([nn]goalposind);????%注意返回的列和行的位置
%??????[startposystartposx]?=?ind2sub([nn]startposind);
%?????plot(goalposx+0.5goalposy+0.5‘ys‘‘MarkerSize‘6‘LineWidth‘4);?????%加0.5是為了把坐標移到方塊中央,‘ys‘中y表示yellows表示Square(方形)
%?????plot(startposx+0.5startposy+0.5‘go‘‘MarkerSize‘6‘LineWidth‘4);???%‘go‘中g表示greeno表示Circle(圓形)
?????%?add?a?button?so?that?can?re-do?the?demonstration??
%?uicontrol(‘style‘‘pushbutton‘‘String‘‘RE-DO‘?‘FontSize‘12?...
%??????????‘Position‘?[10?10?60?40]?‘Callback‘‘ASTAR‘);
?%?end?of?this?function?
%??writerObj?=?VideoWriter(‘ASTAR2.avi‘);
%?open(writerObj);
tic
while?true?%ismember(AB)返回與A同大小的矩陣,其中元素1表示A中相應位置的元素在B中也出現,0則是沒有出現
??%?for?the?element?in?OPEN?with?the?smallest?cost
??field(startposind?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-04-22?12:23??單機器人多任務路徑規劃\
?????文件???????17525??2019-04-19?22:31??單機器人多任務路徑規劃\ASTAR2.m
?????文件????????3696??2019-04-19?22:29??單機器人多任務路徑規劃\bfs.m
?????目錄???????????0??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\
?????文件????????1333??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\PackagingLog.html
?????目錄???????????0??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_redistribution\
?????文件?????1582592??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_redistribution\MyAppInstaller_web.exe
?????目錄???????????0??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_redistribution_files_only\
?????文件???????47612??2013-06-20?09:02??單機器人多任務路徑規劃\robot_allocation3\for_redistribution_files_only\default_icon.ico
?????文件????????1521??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_redistribution_files_only\readme.txt
?????文件??????909393??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_redistribution_files_only\robotallocation1.exe
?????文件???????52266??2015-06-25?09:08??單機器人多任務路徑規劃\robot_allocation3\for_redistribution_files_only\splash.png
?????目錄???????????0??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_testing\
?????文件????????1025??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_testing\mccExcludedFiles.log
?????文件????????1521??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_testing\readme.txt
?????文件??????????12??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_testing\requiredMCRProducts.txt
?????文件??????909393??2019-04-19?19:45??單機器人多任務路徑規劃\robot_allocation3\for_testing\robotallocation1.exe
?????文件???????52266??2015-06-25?09:08??單機器人多任務路徑規劃\robot_allocation3\for_testing\splash.png
?????目錄???????????0??2019-04-20?18:18??單機器人多任務路徑規劃\robot_allocation4\
?????文件????????1333??2019-04-20?18:18??單機器人多任務路徑規劃\robot_allocation4\PackagingLog.html
?????目錄???????????0??2019-04-20?18:18??單機器人多任務路徑規劃\robot_allocation4\for_redistribution\
?????文件?????1587712??2019-04-20?18:18??單機器人多任務路徑規劃\robot_allocation4\for_redistribution\MyAppInstaller_web.exe
?????目錄???????????0??2019-04-20?18:18??單機器人多任務路徑規劃\robot_allocation4\for_redistribution_files_only\
?????文件???????47612??2013-06-20?09:02??單機器人多任務路徑規劃\robot_allocation4\for_redistribution_files_only\default_icon.ico
?????文件????????1521??2019-04-20?18:18??單機器人多任務路徑規劃\robot_allocation4\for_redistribution_files_only\readme.txt
?????文件??????914743??2019-04-20?18:18??單機器人多任務路徑規劃\robot_allocation4\for_redistribution_files_only\robotallocation1.exe
?????文件???????52266??2015-06-25?09:08??單機器人多任務路徑規劃\robot_allocation4\for_redistribution_files_only\splash.png
?????目錄???????????0??2019-04-20?18:18??單機器人多任務路徑規劃\robot_allocation4\for_testing\
?????文件????????1025??2019-04-20?18:17??單機器人多任務路徑規劃\robot_allocation4\for_testing\mccExcludedFiles.log
?????文件????????1521??2019-04-20?18:18??單機器人多任務路徑規劃\robot_allocation4\for_testing\readme.txt
?????文件??????????12??2019-04-20?18:17??單機器人多任務路徑規劃\robot_allocation4\for_testing\requiredMCRProducts.txt
............此處省略7個文件信息
- 上一篇:IIR數字濾波器設計實驗報告
- 下一篇:悉尼大學SLAM實驗數據MATLAB版
評論
共有 條評論