forked from azinke/rwu-dataset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrwu.py
353 lines (340 loc) · 10.9 KB
/
rwu.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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
"""Entrypoint of the package."""
import sys
import argparse
import matplotlib
matplotlib.use("WebAgg")
import matplotlib.pyplot as plt
from core.dataset import Coloradar
from core.utils.common import info, success
def main () -> None:
"""Main entry point for the cli interface."""
parser = argparse.ArgumentParser(
prog="rwu.py",
description="Facility for interacting with the RWU dataset."
)
parser.add_argument(
"-v", "--version",
help="Print software version and information about the dataset.",
action="store_true"
)
parser.add_argument(
"-o", "--overview",
help="Print the dataset JSON description file",
action="store_true"
)
parser.add_argument(
"--codename",
help="Render the available sub-datasets and their codename",
action="store_true"
)
parser.add_argument(
"-d", "--dataset",
type=str,
help="Codename of the sub-dataset record to load"
)
parser.add_argument(
"-i", "--index",
type=int,
help="Index of the dataset entry to read"
)
parser.add_argument(
"--lidar",
help="Render the lidar pointcloud",
action="store_true"
)
parser.add_argument(
"--velodyne",
help="Render the Velodyne lidar pointcloud",
action="store_true"
)
parser.add_argument(
"--ccradar",
help="Render the cascade chip radar pointcloud",
action="store_true"
)
parser.add_argument(
"--raw",
help="Consider radar ADC measurement (only for scradar and ccradar)",
action="store_true"
)
parser.add_argument(
"--heatmap",
help="Render heatmap (only for scradar and ccradar)",
action="store_true"
)
parser.add_argument(
"-pcl", "--pointcloud",
help="Render 3D pointcloud (only for scradar and ccradar)",
action="store_true"
)
parser.add_argument(
"--heatmap-2d",
help="Render 2D heatmap (only for scradar and ccradar)",
action="store_true"
)
parser.add_argument(
"--threshold",
help="Threshold for filtering heatmap pointcloud",
type=float,
default=0.25,
)
parser.add_argument(
"--no-sidelobe",
help="Skip the data within the first couple of meters to avoid sidelobes",
action="store_true",
default=False,
)
parser.add_argument(
"--velocity-view",
help=(
"Render the radar heatmap using velocity as the fourth dimension."
" By default, this parameter is false and the gain in dB is used"
"instead. However, it's only available for the processed raw ADC "
"samples."
),
action="store_true",
default=False,
)
parser.add_argument(
"--camera-view",
"-cv",
help="Request a camera view rendering",
action="store_true",
default=False
)
parser.add_argument(
"--bird-eye-view",
"-bev",
help="Request a bird eye view rendering",
action="store_true",
default=False
)
parser.add_argument(
"--resolution",
"-r",
help="Bird eye view resolution",
type=float,
default=0.05,
)
parser.add_argument(
"--width",
help="Bird eye view image width",
type=float,
default=80.0,
)
parser.add_argument(
"--height",
help="Bird eye view image height",
type=float,
default=80.0,
)
parser.add_argument(
"--groundtruth",
help="Render the bounding box wrapping the groundtruth objects "
"a given dataset entry",
action="store_true"
)
# Parameters to control the rendering of the heatmap
parser.add_argument(
"--range",
help="Range to focus the heatmap on",
type=float,
default=None
)
parser.add_argument(
"--min-range",
help="Min Range to render in the heatmap",
type=float,
default=None
)
parser.add_argument(
"--max-range",
help="Max Range to render in the heatmap",
type=float,
default=None
)
parser.add_argument(
"--azimuth",
help="Azimuth to focus the heatmap on",
type=float,
default=None
)
parser.add_argument(
"--min-azimuth",
help="Azimuth to focus the heatmap on",
type=float,
default=None
)
parser.add_argument(
"--max-azimuth",
help="Azimuth to focus the heatmap on",
type=float,
default=None
)
parser.add_argument(
"--polar",
help="Render heatmap in polar coordinate. "
"Carterian coordinate is used by default otherwise",
action="store_true",
default=False
)
parser.add_argument(
"-si", "--start-index",
type=int,
help="Index of the dataset entry to start the batch processing from",
default=1,
)
parser.add_argument(
"-s", "--save-as",
help="Save post-processed ADC samples in files. Values: 'csv', 'bin'",
type=str,
default="",
)
parser.add_argument(
"--save-to",
help="Destination folder to save the processed data to.",
type=str,
default=None,
)
parser.add_argument(
"--animate",
help="Folder to read input images from",
type=str,
default=None,
)
args = parser.parse_args()
coloradar = Coloradar()
if args.overview:
if args.codename:
coloradar.printCodenames()
sys.exit(0)
print(coloradar)
sys.exit(0)
if args.dataset and args.index:
# Get an instance of the Record class
record = coloradar.getRecord(args.dataset, args.index)
if args.velodyne:
record.load("velodyne")
if args.bird_eye_view:
info("Rendering lidar pointcloud bird eye view ...")
bev = record.lidar.getBirdEyeView(
args.resolution,
(-args.width/2, args.width/2),
(-args.height/2, args.height/2),
)
success("Bird Eye View successfully rendred!")
plt.imshow(bev)
plt.show()
info("Bird Eye View closed!")
sys.exit(0)
info("Rendering lidar pointcloud ...")
record.lidar.show()
success("Successfully closed!")
sys.exit(0)
elif args.ccradar:
record.load("ccradar")
if args.bird_eye_view and (not args.raw):
info("Rendering cascaded chip radar pointcloud bird eye view ...")
bev = record.ccradar.getBirdEyeView(
args.resolution,
(-args.width/2, args.width/2),
(-args.height/2, args.height/2),
)
success("Bird Eye View successfully rendred!")
plt.imshow(bev)
plt.show()
info("Bird Eye View closed!")
sys.exit(0)
elif args.heatmap:
info("Rendering cascade chip radar heatmap ...")
record.ccradar.showHeatmap(args.threshold, args.no_sidelobe)
success("Heatmap closed!")
sys.exit(0)
elif args.raw:
info("Processing raw ADC samples.")
if args.pointcloud:
info("Rendering Radar pointcloud ...")
record.ccradar.showPointcloudFromRaw(
args.velocity_view,
args.bird_eye_view,
args.polar,
camera_view=args.camera_view,
)
success("Successfully closed!")
sys.exit(0)
elif args.heatmap_2d:
info("Rendering 2D heatmap ...")
record.ccradar.show2dHeatmap(args.polar)
sys.exit(0)
info("Rendering 4D heatmap ...")
record.ccradar.showHeatmapFromRaw(
args.threshold,
args.no_sidelobe,
args.velocity_view,
args.polar,
(args.min_range, args.max_range),
(args.min_azimuth, args.max_azimuth),
)
success("Successfully closed!")
sys.exit(0)
info("Rendering cascade chip radar pointcloud ...")
record.ccradar.show()
sys.exit(0)
elif args.dataset and args.save_to:
record = coloradar.getRecord(args.dataset, 0)
if args.velodyne:
info(f"Generated batches of lidar heatmap from '{args.dataset}'")
record.process_and_save(
"velodyne",
resolution=args.resolution,
srange=(-args.width/2, args.width/2),
frange=(-args.height/2, args.height/2),
output=args.save_to,
)
success("BEV generated with success!")
sys.exit(0)
elif args.ccradar and args.raw:
info(f"Generating batches of radar heatmap from '{args.dataset}'")
if args.heatmap_2d:
record.process_and_save(
"ccradar",
heatmap_3d=False,
output=args.save_to,
)
success("Radar 2D heatmap generated with success!")
sys.exit(0)
if args.pointcloud:
record.process_and_save(
"ccradar",
output=args.save_to,
velocity_view=args.velocity_view,
bird_eye_view=args.bird_eye_view,
polar=args.polar,
start_index=args.start_index,
camera_view=args.camera_view,
pointcloud=True,
save_as=args.save_as,
)
success("Radar pointcloud generated with success!")
sys.exit(0)
record.process_and_save(
"ccradar",
output=args.save_to,
threshold=args.threshold,
no_sidelobe=args.no_sidelobe,
velocity_view=args.velocity_view,
start_index=args.start_index,
camera_view=args.camera_view,
heatmap_3d=True,
)
success("Radar 3D heatmap generated with success!")
sys.exit(0)
elif args.dataset and args.animate:
record = coloradar.getRecord(args.dataset, 0)
record.make_video(args.animate)
success("Animation generated with success!")
sys.exit(0)
parser.print_help()
sys.exit(0)
if __name__ == "__main__":
main()