资源简介
用matlab编码实现RRT的路径规划算法,本人亲自修编,matlab2009版本,保证好用,是一个不错的参考程序。
代码片段和文件信息
%% pathRRT
%% - create a path from a start node to an end node
%% using the RRT algorithm.
%% - RRT = Rapidly-exploring Random Tree
%%
%% 赵燕江修改版
function pathRRT;
% create random world
Size = 100;
NumObstacles = 100;
world = createWorld(NumObstacles[Size; Size][0;0]);
% standard length of path segments
segmentLength = 5;
% randomly select start and end nodes
start_node = generateRandomNode(world);
end_node = generateRandomNode(world);
% establish tree starting with the start node
tree = start_node;
% check to see if start_node connects directly to end_node
if ( (norm(start_node(1:2)-end_node(1:2)) &(collision(start_nodeend_nodeworld)==0) )
path = [start_node; end_node];
else
numPaths = 0;
while numPaths<1
[treeflag] = extendTree(treeend_nodesegmentLengthworld);
numPaths = numPaths + flag;
end
end
% find path with minimum cost to end_node
path = findMinimumPath(treeend_node);
plotWorld(worldpathtree);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% createWorld
%% - create random world with obstacles
%% the first element is the north coordinate
%% the second element is the south coordinate
function world = createWorld(NumObstacles NEcorner SWcorner);
% check to make sure that the region is nonempty
if (NEcorner(1) <= SWcorner(1)) | (NEcorner(2) <= SWcorner(2))
disp(‘Not valid corner specifications!‘)
world=[];
% create world data structure
else
world.NumObstacles = NumObstacles;
world.NEcorner = NEcorner;
world.SWcorner = SWcorner;
% create NumObstacles
maxRadius = min(NEcorner(1)- SWcorner(1) NEcorner(2)-SWcorner(2));
maxRadius = 5*maxRadius/NumObstacles/2;
for i=1:NumObstacles
% randomly pick radius
world.radius(i) = maxRadius*rand;
% randomly pick center of obstacles
cn = SWcorner(1) + world.radius(i)...
+ (NEcorner(1)-SWcorner(1)-2*world.radius(i))*rand;
ce = SWcorner(2) + world.radius(i)...
+ (NEcorner(2)-SWcorner(2)-2*world.radius(i))*rand;
world.cn(i) = cn;
world.ce(i) = ce;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% generateRandomNode
%% create a random node (initialize)
function node=generateRandomNode(world);
% randomly pick configuration
pn = (world.NEcorner(1)-world.SWcorner(1))*rand;
pe = (world.NEcorner(2)-world.SWcorner(2))*rand;
chi = 0;
cost = 0;
node = [pn pe chi cost 0];
% check collision with obstacle
while collision(node node world)
pn = (world.NEcorner(1)-world.SWcorner(1))*rand;
pe = (world.NEcorner(2)-world.SWcorner(2))*rand;
chi = 0;
cost = 0;
node = [pn pe chi cost 0];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
相关资源
- 使用matlab画ORBSLAM2运行保存的轨迹文件
- 循环码性能的MATLAB
- GS算法的MATLAB代码
- SINS捷联惯导解算程序
- MATLAB观测器
- 直线阵和圆阵数字波束形成MatlAB程序
- 模拟电压波动与闪变的Matlab文件
- 粒子滤波算法 matlab
- OFDM调制程序 MATLAB
- 简单的声音滤波 matlab
- 基于栅格地图的Dijkstra算法路径规划
- Matlab一维FDTD卷积边界条件CPML
- SMOTE结合SVM算法matlab实现
- MATLAB文字识别程序解析
- 基于MATLAB的血管三维重建
- Allan方差计算程序Matlab版
- Goldstein_Filter
- matlab 图像加噪去噪
- 随机相位正弦波仿真实验MATLAB程序
- MATLAB图像识别80192
- 模糊神经网络matlab源程序
- 三维B样条函数的matlab实现
- 基于matlab的工件缺陷检测
- matlab生成可见性图程序
- matlab 图像校正
- matlab编写的流体计算和传热程序
- 基于粒子群优化算法的模糊c聚类源码
- ACSS角点检测程序
- MUSIC算法的DOA估计的matlab仿真程序
- capon算法Doa估计测角精度仿真matlab
评论
共有 条评论