-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrewire.m
30 lines (30 loc) · 1002 Bytes
/
rewire.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function RRTree=rewire(RRTree,x_new,data)
numcontrolsamples=25;
maxlinearvel = 60;
maxsteerangle = 0.6;
I_r=findNNwithinCircle(RRTree,x_new);
x_near=x_new;
deltastep=5;
for i=1:size(I_r,1)
x_rand=RRTree(I_r,1:2);
for i = 1:numcontrolsamples
linearvel= maxlinearvel*rand;
steerangl= maxsteerangle*(rand*2-1);
[xnew, isValid, rollout,time] = simulate_carBot(data, xnear, xrand, deltastep, linearvel, steerangl);
if isValid
dist=distanceCost(xnew,xnear);
anddiff= xnew-RRTree(I_r,3);
if dist<distance2xrand & angdiff <
x_new=xnew;
rollout_=rollout;
lvel=linearvel;
lang=steerangl;
ltime=time;
ltotaltime=time+Timecost;
% plot(rollout(:,1),rollout(:,2));
% hold on
% drawnow
end
end
end
end