资源简介
自己使用matlab编写的RRT算法,代码较为简单,分为了几个不同的M文件,便于初学者理解随机树模型的可行域、路径检测等

代码片段和文件信息
% ?Rahul Kala IIIT Allahabad Creative Commons Attribution-ShareAlike 4.0 International License.
% The use of this code its parts and all the materials in the text; creation of derivatives and their publication; and sharing the code publically is permitted without permission.
% Please cite the work in all materials as: R. Kala (2014) Code for Robot Path Planning using Rapidly-exploring Random Trees Indian Institute of Information Technology Allahabad Available at: http://rkala.in/codes.html
map=im2bw(imread(‘map1.bmp‘)); % input map read from a bmp file. for new maps write the file name here
source=[10 10]; % source position in Y X format
goal=[490 490]; % goal position in Y X format
stepsize=20; % size of each step of the RRT
disTh=20; % nodes closer than this threshold are taken as almost the same
maxFailedAttempts = 10000;
display=true; % display of RRT
%%%%% parameters end here %%%%%
tic;
if ~feasiblePoint(sourcemap) error(‘source lies on an obstacle or outside map‘); end
if ~feasiblePoint(goalmap) error(‘goal lies on an obstacle or outside map‘); end
if display imshow(map);rectangle(‘position‘[1 1 size(map)-1]‘edgecolor‘‘k‘); end
RRTree=double([source -1]); % RRT rooted at the source representation node and parent index
failedAttempts=0;
counter=0;
pathFound=false;
while failedAttempts<=maxFailedAttempts % loop to grow RRTs
if rand < 0.5
sample=rand(12) .* size(map); % random sample
else
sample=goal; % sample taken as goal to bias tree generation to goal
end
[A I]=min( distanceCost(RRTree(:1:2)sample) []1); % find closest as per the function in the metric node to the sample
closestNode = RRTree(I(1)1:2);
theta=atan2(sample(1)-closestNode(1)sample(2)-closestNode(2)); % direction to extend sample to produce new node
newPoint = double(int32(closestNode(1:2) + stepsize * [sin(theta) cos(theta)]));
if ~checkPath(closestNode(1:2) newPoint map) % if extension of closest node in tree to the new point is feasible
failedAttempts=failedAttempts+1;
continue;
end
if distanceCost(newPointgoal) [A I2]=min( distanceCost(RRTree(:1:2)newPoint) []1); % check if new node is not already pre-existing in the tree
if distanceCost(newPointRRTree(I2(1)1:2)) RRTree=[RRTree;newPoint I(1)]; % add node
failedAttempts=0;
if display
line([closestNode(2);newPoint(2)][closestNode(1);newPoint(1)]);
counter=counter+1;M(counter)=getframe;
end
end
if display && pathFound
line([closestNode(2);goal(2)][closestNode(1);goal(1)]);
counter=counter+1;M(counter)=getframe;
end
if display
disp(‘click/press any key‘);
waitforbuttonpress;
end
if ~pathFound error(‘no path found. maximum attempts reached‘); end
path=[goal];
prev=I(1);
while prev>0
path=[
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3330 2019-04-22 22:03 RRT\astart.m
文件 1011 2019-04-22 22:03 RRT\checkPath.m
文件 590 2019-04-22 22:03 RRT\distanceCost.m
文件 755 2019-04-22 22:03 RRT\feasiblePoint.m
文件 35102 2019-04-22 22:07 RRT\map0.jpg
文件 35382 2019-04-22 22:07 RRT\map1.jpg
文件 49067 2019-04-22 22:08 RRT\map2.jpg
文件 27911 2019-04-22 22:08 RRT\map3.jpg
文件 26771 2019-04-22 22:09 RRT\map4.jpg
文件 210658 2014-06-06 15:35 RRT\RRT.pdf
目录 0 2019-04-22 22:09 RRT
----------- --------- ---------- ----- ----
390577 11
相关资源
- 高灵敏度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实现
- matlab识别系统
评论
共有 条评论