资源简介
自己使用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
相关资源
-
Matlab下Simuli
nk搭建单轮四分之一车辆 -
simuli
nk电弧模型 - 电力系统可靠性评估matlab编程
- 加注释完整CEEMD程序的matlab代码
- Sigma Delta ADC matlab全系统仿真.zip
- 基于椭圆雷达定位的matlab仿真
- 车辆ABS系统滑移率Bang-Bang、PID控制模
- 列车追踪间隔距离仿真
- MATLAB多种改进直方图均衡化
- 双边滤波图像处理方法MATLAB程序
- MATLAB:图像旋转与插值
- 模糊C均值聚类算法
- matlab整流电路
- matlab画雷达图
- matlab心电信号滤波R波提取
- FBG反射谱透射率的MATlab仿真,基于耦
- matlab2016
- 第二版 PDF 李国勇智能预测控制及其
- 基于matlab的PLL锁相环
-
MATLAB/Simuli
nk控制论电弧仿真模型 接 - 合成孔径雷达的BP成像算法
- matlab互信息法求延迟时间
- 动态NSGA-II算法matlab代码
- LMS自适应滤波器MATLAB代码
- 基于MATLAB和FPGA的CIC滤波器.zip
- 路面谱密度matlab代码
- 通过matalb实现图形学中的扫描线填充
- 反步控制轨迹跟踪算法
- Surf特征匹配Matlab代码
- 支持向量机三分类算法
评论
共有 条评论