forked from Chuanyok/Variable-Sampling-Region-RRT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckPath.m
More file actions
17 lines (16 loc) · 695 Bytes
/
checkPath.m
File metadata and controls
17 lines (16 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
%% RRT algorithm
% YU CHUANGYANG Waseda University
% Code for Robot Path Planning using Rapidly-exploring Random Trees
%%
function feasible=checkPath(n,newPos,map)
feasible=true;
if ~feasiblePoint(newPos,map), feasible=false; return;end
dir=atan2(newPos(1)-n(1),newPos(2)-n(2));
for r=0.5:0.5:sqrt(sum((n-newPos).^2))
posCheck=n+r.*[sin(dir) cos(dir)];
if ~(feasiblePoint(ceil(posCheck),map) && feasiblePoint(floor(posCheck),map) && ...
feasiblePoint([ceil(posCheck(1)) floor(posCheck(2))],map) && feasiblePoint([floor(posCheck(1)) ceil(posCheck(2))],map))
feasible=false;break;
end
% if ~feasiblePoint(newPos,map), feasible=false; end
end