【路径规划】 A_star算法机器人动静态避障路径规划【含Matlab源码 371期】

在这里插入图片描述

⛄一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【路径规划】基于matlab A_star算法机器人动静态避障路径规划【含Matlab源码 371期】

获取代码方式2:
付费专栏Matlab路径规划(初级版)

备注:
点击上面蓝色字体付费专栏Matlab路径规划(初级版),扫描上面二维码,付费29.9元订阅海神之光博客付费专栏Matlab路径规划(初级版),凭支付凭证,私信博主,可免费获得1份本博客上传CSDN资源代码(有效期为订阅日起,三天内有效);
点击CSDN资源下载链接:1份本博客上传CSDN资源代码

⛄二、简介

机器人由当前点向目标点运动的过程中,所处环境经常为动态变化且未知的,这使得传统的路径规划算法对于移动机器人避障过程很难建立精确的数学模型。为此,针对环境信息完全未知的情况,为移动机器人设计一种基于模糊控制思想的多行为局部路径规划方法。该方法通过对各种行为之间进行适时合理的切换,以保证机器人安全迅速地躲避静态和动态障碍物,并利用改进的人工势场法实现对变速目标。

⛄三、部分源代码

%% % 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;%起点坐标
start2=2;
goal1=10;%终点坐标
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把数组中元素下标转换为该元素在数组中对应的索引值
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 对于每个网格单元,这个数组保存其父节点的索引。
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

⛄四、运行结果

在这里插入图片描述

⛄五、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1]宋宇,王志明.改进A星算法移动机器人路径规划[J].长春工业大学学报. 2019,40(02)

3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除

  • 26
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab领域

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值