|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | import argparse |
16 | | -from typing import List |
| 16 | +from typing import Optional |
17 | 17 |
|
18 | 18 | # Import different modules for internal and external |
19 | 19 | try: |
20 | | - from projectaria_tools_internal import data_provider |
| 20 | + from projectaria_tools_internal.data_provider import create_vrs_data_provider |
21 | 21 | except ImportError: |
22 | | - from projectaria_tools.core import data_provider |
| 22 | + from projectaria_tools.core.data_provider import create_vrs_data_provider |
23 | 23 |
|
24 | | -import rerun as rr |
25 | | -from projectaria_tools.core.calibration import DeviceVersion |
| 24 | +from projectaria_tools.core.calibration import DeviceCalibration, DeviceVersion |
| 25 | +from projectaria_tools.core.data_provider import DeliverQueuedOptions, VrsDataProvider |
26 | 26 | from projectaria_tools.core.sensor_data import SensorDataType, TimeDomain, TimeSyncMode |
27 | 27 | from projectaria_tools.tools.aria_rerun_viewer.aria_data_plotter import ( |
28 | 28 | AriaDataViewer, |
|
68 | 68 | MAX_IMU_BATCH_SIZE = 500 |
69 | 69 |
|
70 | 70 |
|
71 | | -def parse_subsample_rates(subsampling_args: List[str], enabled_streams: List[str]): |
| 71 | +def parse_subsample_rates(subsampling_args: list[str], enabled_streams: list[str]): |
72 | 72 | """ |
73 | 73 | This is a helper function to parse CLI input of subsample rates for each stream |
74 | 74 |
|
@@ -133,7 +133,7 @@ def parse_args(): |
133 | 133 |
|
134 | 134 | def get_deliver_option( |
135 | 135 | vrs_data_provider, |
136 | | - enabled_stream_labels: List[str] = None, |
| 136 | + enabled_stream_labels: list[str] = None, |
137 | 137 | subsample_rates: dict = None, |
138 | 138 | viewer_config: AriaDataViewerConfig = None, |
139 | 139 | skip_begin_sec: float = None, |
@@ -299,54 +299,72 @@ def plot_queued_sensor_data(vrs_data_provider, deliver_options, aria_data_viewer |
299 | 299 | aria_data_viewer.plot_hand_pose_data_3d(data.hand_pose_data()) |
300 | 300 |
|
301 | 301 |
|
302 | | -def main(): |
303 | | - args = parse_args() |
| 302 | +def log_vrs_to_rerun( |
| 303 | + vrs: str, |
| 304 | + rrd_output_path: str = "", |
| 305 | + subsample_rates: Optional[list[str]] = None, |
| 306 | + enabled_streams: Optional[list[str]] = None, |
| 307 | + skip_begin_sec: Optional[float] = None, |
| 308 | + skip_end_sec: Optional[float] = None, |
| 309 | +) -> None: |
304 | 310 | # Step 1: Create VRS data provider |
305 | | - vrs_data_provider = data_provider.create_vrs_data_provider(args.vrs) |
| 311 | + vrs_data_provider: VrsDataProvider = create_vrs_data_provider(vrs) |
306 | 312 | if not vrs_data_provider: |
307 | | - print(f"Failed to open {args.vrs}") |
| 313 | + print(f"Failed to open {vrs}") |
308 | 314 | return |
309 | 315 |
|
310 | 316 | # Step 2: Extract device_calibration from vrs_data_provider |
311 | | - device_calibration = vrs_data_provider.get_device_calibration() |
312 | | - device_version = device_calibration.get_device_version() |
| 317 | + device_calibration: DeviceCalibration = vrs_data_provider.get_device_calibration() |
| 318 | + device_version: DeviceVersion = device_calibration.get_device_version() |
313 | 319 | if device_version == DeviceVersion.Gen1: |
314 | | - all_stream_labels = ALL_STREAM_LABELS_GEN1 |
| 320 | + all_stream_labels: list[str] = ALL_STREAM_LABELS_GEN1 |
315 | 321 | elif device_version == DeviceVersion.Gen2: |
316 | | - all_stream_labels = ALL_STREAM_LABELS_GEN2 |
| 322 | + all_stream_labels: list[str] = ALL_STREAM_LABELS_GEN2 |
317 | 323 | else: |
318 | 324 | raise ValueError(f" Unsupported Aria device version: {device_version}") |
319 | 325 |
|
320 | 326 | # Step 3: Create config |
321 | | - viewer_config = AriaDataViewerConfig() |
| 327 | + viewer_config: AriaDataViewerConfig = AriaDataViewerConfig() |
322 | 328 | viewer_config.enable_gps = True |
323 | 329 |
|
324 | 330 | # Step 4: Get configured deliver options |
325 | | - parsed_subsample_rates = ( |
326 | | - parse_subsample_rates(args.subsample_rates, all_stream_labels) |
327 | | - if args.subsample_rates |
| 331 | + parsed_subsample_rates: dict[str, int] = ( |
| 332 | + parse_subsample_rates(subsample_rates, all_stream_labels) |
| 333 | + if subsample_rates |
328 | 334 | else {} |
329 | 335 | ) |
330 | | - deliver_options = get_deliver_option( |
| 336 | + deliver_options: DeliverQueuedOptions = get_deliver_option( |
331 | 337 | vrs_data_provider=vrs_data_provider, |
332 | | - enabled_stream_labels=args.enabled_streams or all_stream_labels, |
| 338 | + enabled_stream_labels=enabled_streams or all_stream_labels, |
333 | 339 | subsample_rates=parsed_subsample_rates, |
334 | 340 | viewer_config=viewer_config, |
335 | | - skip_begin_sec=args.skip_begin_sec, |
336 | | - skip_end_sec=args.skip_end_sec, |
| 341 | + skip_begin_sec=skip_begin_sec, |
| 342 | + skip_end_sec=skip_end_sec, |
337 | 343 | ) |
338 | 344 |
|
339 | 345 | # Step 6: Initialize AriaDataViewer |
340 | | - aria_data_viewer = AriaDataViewer( |
| 346 | + aria_data_viewer: AriaDataViewer = AriaDataViewer( |
341 | 347 | config=viewer_config, |
342 | 348 | device_calibration=device_calibration, |
343 | | - rrd_output_path=args.rrd_output_path, |
| 349 | + rrd_output_path=rrd_output_path, |
344 | 350 | ) |
345 | 351 | aria_data_viewer.plot_device_extrinsics() |
346 | 352 |
|
347 | 353 | # Step 6: Plot queued sensor data |
348 | 354 | plot_queued_sensor_data(vrs_data_provider, deliver_options, aria_data_viewer) |
349 | 355 |
|
350 | 356 |
|
| 357 | +def main(): |
| 358 | + args = parse_args() |
| 359 | + log_vrs_to_rerun( |
| 360 | + vrs=args.vrs, |
| 361 | + rrd_output_path=args.rrd_output_path, |
| 362 | + subsample_rates=args.subsample_rates, |
| 363 | + enabled_streams=args.enabled_streams, |
| 364 | + skip_begin_sec=args.skip_begin_sec, |
| 365 | + skip_end_sec=args.skip_end_sec, |
| 366 | + ) |
| 367 | + |
| 368 | + |
351 | 369 | if __name__ == "__main__": |
352 | 370 | main() |
0 commit comments