-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.m
executable file
·188 lines (157 loc) · 5.02 KB
/
Main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
close all
clear all
clc;
% parameter
sample_quality=10;
%% loading preprocessed data / settings
addpath('./mapping');
addpath('./trajectory');
% landuse=load('landuse_amsterdam.mat');
% landuse=load('landuse_manhattan.mat');
% image=imread('manhattan_landuse.png');
% dem=load('dem_manhattan.mat');
image=imread('seoul_landuse.png');
landuse=load('landuse_seoul.mat');
dem=load('dem_seoul.mat');
slope=dem.slope;
height=dem.height;
town=landuse.landuse{1};
landuse=landuse.landuse{2}; %handle this one
% aircraft status
initial=[502,1093,pi/4]; % for seoul
% initial=[286,958,-pi/4*3]; %for manhattan
altitude=1; %km
vel= 250; %km/h
delay = 10; %s
%% rwy generation
tic
[point,matrix]=boundary_pointgen(landuse,sample_quality);
disp('=== feasible area selection complete ===');
[rwy,k]=rwy_gen(point,landuse,height);
disp('=== runway generation complete ===');
A=[num2str(k),' runway candidates'];
disp(A);
% pixel dimension output
%% trajectory generation
altitude = altitude*33; %in pixel
[couple_set,k]=traj_gen(rwy,initial,altitude,1,vel,delay); %rwy info. + traj info.
disp('=== trajectory generation complete ===');
A=[num2str(k),' possible combinations'];
disp(A);
%km-s dimension
traj=couple_set.traj;
%% Evaluation
[ascore,tscore,r,CG]=scoring(couple_set,slope,town);
ascore(:,4)=sum(ascore,2);
disp('=== evaluation complete ===');
%% Filter out meaningless selections - Pareto front selection
setnum=pareto_frontier(ascore,tscore); %Meaningful ones survive
finalset=[];
a=1;
for i = 1:length(setnum)
finalset.traj{a}=couple_set.traj(setnum(i),:);
finalset.rwy{a}=couple_set.rwy(setnum(i),:);
a=a+1;
score_set(i,1)=tscore(setnum(i),4);
score_set(i,2)=ascore(setnum(i),4);
end
%% Post process - sorting
[B,I]=sort(score_set);
I1=I(:,1);
B=score_set(:,2);
score_set=[score_set(I1),B(I1)];
finalset.traj=finalset.traj(I);
finalset.rwy=finalset.rwy(I);
% traj=couple_set.traj;
% colorimage=imread('colormap_seoul.png');
% imshow(colorimage)
% for i = 1:length(rwy)
% hold on
% plot([rwy{i}{1}(2),rwy{i}{2}(2)],[rwy{i}{1}(1),rwy{i}{2}(1)],'b')
% end
% for i = 1:length(traj(:,1))
% hold on
% plot(traj{i}(:,2),traj{i}(:,1),'r')
% % A=num2str(ascore(i,4));
% % text(couple_set.rwy{i}{1}(2), couple_set.rwy{i}{1}(1),A,'HorizontalAlignment','center');
% text(couple_set.rwy{i}{1}(2), couple_set.rwy{i}{1}(1),num2str(i),'VerticalAlignment','top');
% text(couple_set.rwy{i}{2}(2), couple_set.rwy{i}{2}(1),num2str(i),'VerticalAlignment','top');
% end
%
%objective space
%% Visualize
%objective space plot
figure('name','objective space');
hold on
plot(tscore(:,4),ascore(:,4),'o') % -> Case on Obejctive space
for i = 1:length(setnum)
hold on
plot(tscore(setnum(i),4),ascore(setnum(i),4),'ro-');
end
hold on
plot(score_set(:,1),score_set(:,2));
for i = 1:length(score_set)
text(score_set(i,1), score_set(i,2), num2str(i),'VerticalAlignment','top');
end
% xlim([0 inf])
% ylim([0 inf])
% axis tight
title('objective space','fontsize',15)
xlabel('trajectory score','fontsize',14)
ylabel('area score','fontsize',14)
grid on
%map visualization
colorimage=imread('colormap_seoul.png');
boundary=imread('boundary.png');
figure('name','generated runway');
hold on
% imshow(landuse)
% imshow(image)
imshow(colorimage)
% imshow(boundary)
for i=1:length(point)
hold on
plot(point{i}(2),point{i}(1),'ro')
end
for i = 1:length(finalset.traj)
hold on
plot(finalset.traj{i}{1}(:,2),finalset.traj{i}{1}(:,1),'g')
plot([finalset.rwy{i}{1}{1}(2),finalset.rwy{i}{1}{2}(2)],[finalset.rwy{i}{1}{1}(1),finalset.rwy{i}{1}{2}(1)],'b')
% text(finalset.rwy{i}{1}{1}(2), finalset.rwy{i}{1}{1}(1),num2str(i),'VerticalAlignment','top');
text(finalset.rwy{i}{1}{2}(2), finalset.rwy{i}{1}{2}(1),num2str(i),'VerticalAlignment','top');
end
hold on
quiver(initial(2), initial(1), cos(initial(3))*40, sin(initial(3))*40, 'MaxHeadSize', 3)
[X,Y]=circle(CG(2),CG(1),r);
plot(X,Y)
scatter(initial(2), initial(1), 'x')
scatter(CG(2),CG(1),'filled','d','r')
%% 3D visualize
figure('name','3D');
for i = 1:length(finalset.traj)
hold on
plot3(finalset.traj{i}{1}(:,2),finalset.traj{i}{1}(:,1),finalset.traj{i}{1}(:,3)*30,'g')
plot([finalset.rwy{i}{1}{1}(2),finalset.rwy{i}{1}{2}(2)],[finalset.rwy{i}{1}{1}(1),finalset.rwy{i}{1}{2}(1)],'b')
% text(finalset.rwy{i}{1}{1}(2), finalset.rwy{i}{1}{1}(1),num2str(i),'VerticalAlignment','top');
text(finalset.rwy{i}{1}{2}(2), finalset.rwy{i}{1}{2}(1),num2str(i),'VerticalAlignment','top');
end
hold on
surf(flipud(height))
shading interp
axis equal
%display
disp('=== visualization complete ===')
A=[num2str(length(setnum)),' reasonable choices generated'];
disp(A)
disp(' ')
disp('==========================')
disp('==== Process Complete ====')
disp('==========================')
disp(' ')
toc
%% define function
function [xp,yp]=circle(x,y,r)
ang=0:pi/180:2*pi;
xp=r*cos(ang)+x;
yp=r*sin(ang)+y;
end