?一、獲取代碼方式
獲取代碼方式1:
完整代碼已上傳我的資源:【路徑規(guī)劃】基于matlab A_star算法機(jī)器人動靜態(tài)避障路徑規(guī)劃【含Matlab源碼 371期】
獲取代碼方式2:
付費(fèi)專欄Matlab路徑規(guī)劃(初級版)
備注:
點(diǎn)擊上面藍(lán)色字體付費(fèi)專欄Matlab路徑規(guī)劃(初級版),掃描上面二維碼,付費(fèi)29.9元訂閱海神之光博客付費(fèi)專欄Matlab路徑規(guī)劃(初級版),憑支付憑證,私信博主,可免費(fèi)獲得1份本博客上傳CSDN資源代碼(有效期為訂閱日起,三天內(nèi)有效);
點(diǎn)擊CSDN資源下載鏈接:1份本博客上傳CSDN資源代碼
?二、簡介
機(jī)器人由當(dāng)前點(diǎn)向目標(biāo)點(diǎn)運(yùn)動的過程中,所處環(huán)境經(jīng)常為動態(tài)變化且未知的,這使得傳統(tǒng)的路徑規(guī)劃算法對于移動機(jī)器人避障過程很難建立精確的數(shù)學(xué)模型。為此,針對環(huán)境信息完全未知的情況,為移動機(jī)器人設(shè)計(jì)一種基于模糊控制思想的多行為局部路徑規(guī)劃方法。該方法通過對各種行為之間進(jìn)行適時合理的切換,以保證機(jī)器人安全迅速地躲避靜態(tài)和動態(tài)障礙物,并利用改進(jìn)的人工勢場法實(shí)現(xiàn)對變速目標(biāo)。
?三、部分源代碼
%% % set up color map for display
cmap = [1 1 1; …% 1 - white - clear cell
0 0 0; …% 2 - black - obstacle
0 1 0; …% 3 - green - start
0 0 1; …% 4 - blue - on list
1 1 0; …% 5 - yellow - destination
1 0 0];% 6 - red = visited
colormap(cmap);
map = zeros(20); %地圖尺寸
start1=10;%起點(diǎn)坐標(biāo)
start2=2;
goal1=10;%終點(diǎn)坐標(biāo)
goal2=18;
% Add an obstacle
map (6:16, 7) = 2;
map (6, 5:6) = 2;
map (16, 5:6) = 2;
map (8:12, 15) = 2;
map(start1,start2) = 5; % start_coords
map(goal1, goal2) = 6; % goal_coords
image(1.5,1.5,map);
grid on;
axis image;
%%
nrows = 20;
ncols = 20;
start_node = sub2ind(size(map), start1,start2); %sub2ind把數(shù)組中元素下標(biāo)轉(zhuǎn)換為該元素在數(shù)組中對應(yīng)的索引值
goal_node = sub2ind(size(map), goal1, goal2);
% Initialize distance array
distanceFromStart = Inf(nrows,ncols);
distanceFromStart(start_node) = 0;
%====================
[X, Y] = meshgrid (1:ncols, 1:nrows);
H = abs(Y - goal1) + abs(X - goal2);
f = Inf(nrows,ncols);
f(start_node) = H(start_node);
%=======================
% For each grid cell this array holds the index of its parent 對于每個網(wǎng)格單元,這個數(shù)組保存其父節(jié)點(diǎn)的索引。
parent = zeros(nrows,ncols);
% Main Loop
while true
% Draw current map
map(start_node) = 5;
map(goal_node) = 6;
image(1.5, 1.5, map);
grid on;
axis image;
drawnow;
%====================
% Find the node with the minimum distance
[~, current] = min(f(??);
[min_dist, ~] =min(distanceFromStart(??);
%===================
if ((current == goal_node) || isinf(min_dist))
break;
end;
map(current) = 3;
%============
f(current) = Inf; %無窮大
%============
[i, j] = ind2sub(size(distanceFromStart), current);
neighbor = [i-1,j;… %鄰域
i+1,j;…
i,j+1;…
i,j-1] ;
outRangetest = (neighbor(:,1)<1) + (neighbor(:,1)>nrows) +(neighbor(:,2)<1) + (neighbor(:,2)>ncols ) ;
locate = find(outRangetest>0);
neighbor(locate,:)=[] ;
neighborIndex = sub2ind(size(map),neighbor(:,1),neighbor(:,2)) ;
for i=1:length(neighborIndex)
if (map(neighborIndex(i))~=2) && (map(neighborIndex(i))~=3 && map(neighborIndex(i))~= 5)
map(neighborIndex(i)) = 4;
if distanceFromStart(neighborIndex(i))> min_dist + 1
distanceFromStart(neighborIndex(i)) = min_dist+1;
parent(neighborIndex(i)) = current;
f(neighborIndex(i)) =H(neighborIndex(i));
end
end
end
end
?四、運(yùn)行結(jié)果
?五、matlab版本及參考文獻(xiàn)
1 matlab版本
2014a
2 參考文獻(xiàn)
[1]宋宇,王志明.改進(jìn)A星算法移動機(jī)器人路徑規(guī)劃[J].長春工業(yè)大學(xué)學(xué)報. 2019,40(02)文章來源:http://www.zghlxwxcb.cn/news/detail-797874.html
3 備注
簡介此部分摘自互聯(lián)網(wǎng),僅供參考,若侵權(quán),聯(lián)系刪除文章來源地址http://www.zghlxwxcb.cn/news/detail-797874.html
到了這里,關(guān)于【路徑規(guī)劃】 A_star算法機(jī)器人動靜態(tài)避障路徑規(guī)劃【含Matlab源碼 371期】的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!