-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_map.m
51 lines (43 loc) · 2.03 KB
/
create_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 create_map(plan)
global map;
global map_size;
global init_position_x;
global init_position_y;
global goal_position_x;
global goal_position_y;
y_size = size(plan,1);
x_size = size(plan,2);
x_step = floor(map_size/x_size);
y_step = floor(map_size/y_size);
map = ones(map_size,map_size);
for j = 1:y_size
for i = 1:x_size
if plan(j,i) == 1
map(floor((j-1)*map_size/y_size) + 1:floor(j*map_size/y_size), floor((i-1)*map_size/x_size) + 1:floor(i*map_size/x_size)) = 0;
elseif plan(j,i) == 2
init_position_y = floor((j-0.5)*map_size/y_size);
init_position_x = floor((i-0.5)*map_size/x_size);
map(init_position_y, init_position_x) = 0.25;
map(init_position_y + 1, init_position_x + 1) = 0.25;
map(init_position_y + 2, init_position_x + 2) = 0.25;
map(init_position_y + 1, init_position_x - 1) = 0.25;
map(init_position_y + 2, init_position_x - 2) = 0.25;
map(init_position_y - 1, init_position_x + 1) = 0.25;
map(init_position_y - 2, init_position_x + 2) = 0.25;
map(init_position_y - 1, init_position_x - 1) = 0.25;
map(init_position_y - 2, init_position_x - 2) = 0.25;
elseif plan(j,i) == 3
goal_position_y = floor(((2*j-1)*map_size/y_size)/2);
goal_position_x = floor(((2*i-1)*map_size/x_size)/2);
map(goal_position_y, goal_position_x) = 0.25;
map(goal_position_y + 1, goal_position_x + 1) = 0.25;
map(goal_position_y + 1, goal_position_x - 1) = 0.25;
map(goal_position_y - 1, goal_position_x + 1) = 0.25;
map(goal_position_y - 1, goal_position_x - 1) = 0.25;
map(goal_position_y + 2, goal_position_x) = 0.25;
map(goal_position_y - 2, goal_position_x) = 0.25;
map(goal_position_y, goal_position_x + 2) = 0.25;
map(goal_position_y, goal_position_x - 2) = 0.25;
end
end
end