-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
252 lines (208 loc) · 8.9 KB
/
config.py
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
from enum import Enum
import torch
from torch import nn
MIN_DISTANCE_CLASSIFICATION_METERS = 50
CASE_UNKNOWN = 0
CASE_FIXED_WING = 1
CASE_MAVIC_PRO = 2 # aladrian-MAVIC PRO
CASE_PHANTOM_4_PRO = 3 # kcdgc-P4 Professional V2.0
CASE_MAVIC2 = 4 # djiuser_97p9AXasssb6-Mavic2
CASE_PHANTOM4PRO_MAVIC2 = 5
CASE_PHANTOM4PRO_MAVICPRO = 6
POP_GEOSPATIAL_COORDINATES = False
PRINT_LOGS = False
class Net(torch.nn.Module):
def __init__(self, n_features):
super(Net, self).__init__()
self.layers = torch.nn.Sequential(
torch.nn.Linear(n_features, 512 * 512),
torch.nn.ReLU(),
torch.nn.Linear(512 * 512, 7)
)
def forward(self, x):
return self.layers(x)
class Classifications(Enum):
CASE_UNKNOWN = 0
CASE_FIXED_WING = 1
CASE_MAVIC_PRO = 2 # aladrian-MAVIC PRO
CASE_PHANTOM_4_PRO = 3 # kcdgc-P4 Professional V2.0
CASE_MAVIC2 = 4 # djiuser_97p9AXasssb6-Mavic2
CASE_PHANTOM4PRO_MAVIC2 = 5
CASE_PHANTOM4PRO_MAVICPRO = 6
def DronesEstimator(input, print_logs, g, p):
val_alvira = input['AlviraTracksTrack_Classification'] # AlviraTracksTrack_Classification
val_arcus = input['ArcusTracksTrack_Classification'] # ArcusTracksTrack_Classification
val_diana = input['DianaTargetsTargetClassification_type'] # DianaTargetsTargetClassification_type
result = CASE_UNKNOWN
scenario = input['scenario_name']
firstDrone = False
secondDrone = False
xx = input["longitude"]
yy = input["latitude"]
xx2 = input["longitude_2"]
yy2 = input["latitude_2"]
alv_x = input["AlviraTracksTrackPosition_Longitude"]
alv_y = input["AlviraTracksTrackPosition_Latitude"]
arc_x = input["ArcusTracksTrackPosition_Longitude"]
arc_y = input["ArcusTracksTrackPosition_Latitude"]
if scenario == 'Scenario_Parrot_a':
az12, az21, dist = g.inv(xx, yy, alv_x, alv_y)
az12, az21, dist2 = g.inv(xx, yy, arc_x, arc_y)
if print_logs:
print(f"({xx}, {yy});\n({arc_x}, {arc_y}); ({alv_x}, {alv_y})")
print(f"1_alv: {dist}, 1_arc: {dist2}")
if dist < MIN_DISTANCE_CLASSIFICATION_METERS or dist2 < MIN_DISTANCE_CLASSIFICATION_METERS:
if print_logs:
print(f"{bcolors.OKGREEN}Drone FOUND!{bcolors.ENDC}")
result = CASE_FIXED_WING
if scenario == "Scenario_1_1":
az12, az21, dist = g.inv(xx, yy, alv_x, alv_y)
az12, az21, dist2 = g.inv(xx, yy, arc_x, arc_y)
if print_logs:
print(f"({xx}, {yy});\n({arc_x}, {arc_y}); ({alv_x}, {alv_y})")
print(f"1_alv: {dist}, 1_arc: {dist2}")
if dist < MIN_DISTANCE_CLASSIFICATION_METERS or dist2 < MIN_DISTANCE_CLASSIFICATION_METERS:
if print_logs:
print(f"{bcolors.OKGREEN}Drone FOUND!{bcolors.ENDC}")
result = CASE_MAVIC_PRO
if scenario == "Scenario_1_2_b":
az12, az21, dist = g.inv(xx, yy, alv_x, alv_y)
az12, az21, dist2 = g.inv(xx, yy, arc_x, arc_y)
if print_logs:
print(f"({xx}, {yy});\n({arc_x}, {arc_y}); ({alv_x}, {alv_y})")
print(f"1_alv: {dist}, 1_arc: {dist2}")
if dist < MIN_DISTANCE_CLASSIFICATION_METERS or dist2 < MIN_DISTANCE_CLASSIFICATION_METERS:
if print_logs:
print(f"{bcolors.OKGREEN}Drone FOUND!{bcolors.ENDC}")
result = CASE_PHANTOM_4_PRO
if scenario == "Scenario_1_3":
az12, az21, dist = g.inv(xx, yy, alv_x, alv_y)
az12, az21, dist2 = g.inv(xx, yy, arc_x, arc_y)
if print_logs:
print(f"({xx}, {yy});\n({arc_x}, {arc_y}); ({alv_x}, {alv_y})")
print(f"1_alv: {dist}, 1_arc: {dist2}")
if dist < MIN_DISTANCE_CLASSIFICATION_METERS or dist2 < MIN_DISTANCE_CLASSIFICATION_METERS:
if print_logs:
print(f"{bcolors.OKGREEN}Drone FOUND!{bcolors.ENDC}")
result = CASE_MAVIC_PRO
if scenario == "Scenario_1_4":
az12, az21, dist = g.inv(xx, yy, alv_x, alv_y)
az12, az21, dist2 = g.inv(xx, yy, arc_x, arc_y)
if print_logs:
print(f"({xx}, {yy});\n({arc_x}, {arc_y}); ({alv_x}, {alv_y})")
print(f"1_alv: {dist}, 1_arc: {dist2}")
if dist < MIN_DISTANCE_CLASSIFICATION_METERS or dist2 < MIN_DISTANCE_CLASSIFICATION_METERS:
if print_logs:
print(f"{bcolors.OKGREEN}Drone FOUND!{bcolors.ENDC}")
result = CASE_MAVIC2
if scenario == "Scenario_2_1":
az12, az21, dist = g.inv(xx, yy, alv_x, alv_y)
az12, az21, dist2 = g.inv(xx, yy, arc_x, arc_y)
az12, az21, dist3 = g.inv(xx2, yy2, alv_x, alv_y)
az12, az21, dist4 = g.inv(xx2, yy2, arc_x, arc_y)
if print_logs:
print(f"({xx}, {yy});\n({arc_x}, {arc_y}); ({alv_x}, {alv_y})")
print(f"1_alv: {dist}, 1_arc: {dist2}, 2_alv: {dist3}, 2_arc: {dist4}")
if dist < MIN_DISTANCE_CLASSIFICATION_METERS or dist2 < MIN_DISTANCE_CLASSIFICATION_METERS:
if print_logs:
print(f"{bcolors.OKGREEN}First drone FOUND!{bcolors.ENDC}")
firstDrone = True
if dist3 < MIN_DISTANCE_CLASSIFICATION_METERS or dist4 < MIN_DISTANCE_CLASSIFICATION_METERS:
if print_logs:
print(f"{bcolors.OKGREEN}Second drone FOUND!{bcolors.ENDC}")
secondDrone = True
if firstDrone and secondDrone:
result = CASE_PHANTOM4PRO_MAVIC2
else:
if firstDrone:
result = CASE_PHANTOM_4_PRO
if secondDrone:
result = CASE_MAVIC2
if scenario == "Scenario_2_2":
az12, az21, dist = g.inv(xx, yy, alv_x, alv_y)
az12, az21, dist2 = g.inv(xx, yy, arc_x, arc_y)
az12, az21, dist3 = g.inv(xx2, yy2, alv_x, alv_y)
az12, az21, dist4 = g.inv(xx2, yy2, arc_x, arc_y)
if print_logs:
print(f"({xx}, {yy}); ({xx2}, {yy2});\n({arc_x}, {arc_y}); ({alv_x}, {alv_y})")
print(f"1_alv: {dist}, 1_arc: {dist2}, 2_alv: {dist3}, 2_arc: {dist4}")
if dist < MIN_DISTANCE_CLASSIFICATION_METERS or dist2 < MIN_DISTANCE_CLASSIFICATION_METERS:
if print_logs:
print(f"{bcolors.OKGREEN}First drone FOUND!{bcolors.ENDC}")
firstDrone = True
if dist3 < MIN_DISTANCE_CLASSIFICATION_METERS or dist4 < MIN_DISTANCE_CLASSIFICATION_METERS:
if print_logs:
print(f"{bcolors.OKGREEN}Second drone FOUND!{bcolors.ENDC}")
secondDrone = True
if firstDrone and secondDrone:
result = CASE_PHANTOM4PRO_MAVICPRO
else:
if firstDrone:
result = CASE_PHANTOM_4_PRO
if secondDrone:
result = CASE_MAVIC_PRO
# no need for parrot A scenario
if print_logs:
print(f"ALVIRA: {val_alvira}, ARCUS: {val_arcus}, DIANA: {val_diana}, scenario: {scenario}, result: {result}")
print("---")
return result
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
MLP_CLASSIFIER_INPUT_COLUMNS = [
'AlviraTracksTrackPosition_Altitude',
'AlviraTracksTrackVelocity_Azimuth',
'AlviraTracksTrackVelocity_Elevation',
'AlviraTracksTrackVelocity_Speed',
'AlviraTracksTrack_Classification',
'AlviraTracksTrack_Reflection',
'ArcusTracksTrackPosition_Altitude',
'ArcusTracksTrackVelocity_Azimuth',
'ArcusTracksTrackVelocity_Elevation',
'ArcusTracksTrackVelocity_Speed',
'ArcusTracksTrack_Classification',
'ArcusTracksTrack_Reflection'
]
MLP_INPUT_COLUMNS = [
'AlviraTracksTrackPosition_Altitude',
'AlviraTracksTrackVelocity_Azimuth',
'AlviraTracksTrackVelocity_Elevation',
'AlviraTracksTrackVelocity_Speed',
'AlviraTracksTrack_Classification',
'AlviraTracksTrack_Reflection',
'ArcusTracksTrackPosition_Altitude',
'ArcusTracksTrackVelocity_Azimuth',
'ArcusTracksTrackVelocity_Elevation',
'ArcusTracksTrackVelocity_Speed',
'ArcusTracksTrack_Classification',
'ArcusTracksTrack_Reflection',
'DianaTargetsTargetSignal_snr_dB',
'DianaTargetsTargetSignal_bearing_deg',
'DianaTargetsTargetSignal_range_m',
'DianaTargetsTargetClassification_type',
'reference_classification'
]
COLS_TO_STANDARDIZE = [
'AlviraTracksTrackPosition_Altitude',
'AlviraTracksTrackVelocity_Azimuth',
'AlviraTracksTrackVelocity_Elevation',
'AlviraTracksTrackVelocity_Speed',
'AlviraTracksTrack_Reflection',
'AlviraTracksTrack_Score',
'ArcusTracksTrackPosition_Altitude',
'ArcusTracksTrackVelocity_Azimuth',
'ArcusTracksTrackVelocity_Elevation',
'ArcusTracksTrackVelocity_Speed',
'ArcusTracksTrack_Reflection',
'ArcusTracksTrack_Score',
'DianaTargetsTargetSignal_snr_dB',
'DianaTargetsTargetSignal_bearing_deg',
'DianaTargetsTargetSignal_range_m'
]