-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathgen_map.m
51 lines (33 loc) · 970 Bytes
/
gen_map.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function xL = gen_map(nL,v,omega,rmin,rmax, nSteps,dt)
if omega~=0
% radius
r = v/omega;
for i=1:nL
if rand>.5
rho = r + rmin + (rmax-rmin)*rand;
th = 2*pi*rand;
else
rho = r - rmax + (rmax-rmin)*rand;
th = 2*pi*rand;
end
[x,y] = pol2cart(th,rho);
xL(:,i) = [x;y+r]; %shift y w/ r since robot starts at (0,0)
end
end
if omega==0 %exploration case
for i=1:nL
if round(rand)
rho = rmin + (rmax-rmin)*rand;
th = 2*pi*rand;
else
rho = - rmax + (rmax-rmin)*rand;
th = 2*pi*rand;
end
[x,y] = pol2cart(th,rho);
yy(1,i) = rho;%y;
end
dtraj = v*dt*nSteps;
xL = [dtraj*rand(1,nL); yy ];
xL = [1:dtraj/nL:dtraj; yy];
xL = [dtraj*rand(1,nL); dtraj/2*(rand(1,nL)-0.5) ];
end