py123d Documentation

repository·main·Indexed 18 days ago

https://github.com/kesai-labs/py123d

An open-source library for unifying multi-modal autonomous driving datasets—including nuScenes, Waymo, Argoverse 2, CARLA, Griffin, and KITTI-360—into a high-performance Apache Arrow format. It provides a consistent API for accessing cameras, lidar, HD maps, and labels, along with CLI tools for data conversion (py123d-conversion) and 3D visualization (py123d-viser).

Tokens
50.5K
Snippets
163
Records
279
Agent score
62%

What's inside py123d

  1. Overview of 123D features

    main

    123D is a library designed for driving datasets in both 2D and 3D. It provides a unified API to manage various types of data, including sensor data, maps, and labels.

    Key capabilities include:

    • Unified API: A single interface for handling sensor data, maps, and labels.
    • Flexible Storage: Support for multiple sensor storage formats.
    • High Performance: Uses Apache Arrow as a fast data format.
    • Visualization: Integrated tools for data visualization using matplotlib and Viser.
  2. Overview of Physical AI AV dataset

    main

    The Physical AI AV dataset contains autonomous driving sensor data from the NVIDIA Hyperion 8 platform. It is currently considered experimental in py123d support.

    Key Features:

    • Cameras: 7 fisheye (f-theta) cameras at ~30 fps.
    • LiDAR: 360-degree LiDAR at ~10 Hz (Draco-compressed).
    • Egomotion: High-rate data (67-100 Hz) with both real-time and offline-smoothed sources.
    • Detections: Auto-labeled 3D bounding boxes with 10 semantic classes.

    Available Splits:

    • physical-ai-av_train
    • physical-ai-av_val
    • physical-ai-av_test

    Dataset Links:

  3. Griffin coordinate frames and label handling

    main

    Understanding the coordinate systems used in Griffin:

    • LiDAR and Labels: Stored in the ego frame (X-forward, Y-left, Z-up). The parser lifts boxes to the global frame but keeps LiDAR points ego-relative.
    • Poses: Use an ENU world frame with xyz Euler angles in degrees.
    • Label Filtering: Non-traffic CARLA categories (e.g., military props) are skipped during conversion as they fall outside the Griffin perception taxonomy.
  4. nuPlan Modalities and Sensor Overview

    main

    The nuPlan dataset provides several modalities used by py123d.

    ModalityAvailabilityDescription
    Ego VehicleState including poses, dynamic state, and vehicle parameters (py123d.datatypes.EgoStateSE3).
    Map(✓)2D vector HD-Maps (py123d.api.MapAPI).
    Bounding BoxesAvailable detections (py123d.datatypes.BoxDetectionsSE3).
    Traffic LightsStatus and associated lane IDs (py123d.datatypes.TrafficLightDetections).
    Cameras(✓)Subset includes 8 cameras: PCAM_F0 (Front), PCAM_R0/R1/R2 (Right), PCAM_L0/L1/L2 (Left), and PCAM_B0 (Back).
    Lidars(✓)Subset includes 5 Lidars: LIDAR_TOP, LIDAR_FRONT, LIDAR_SIDE_LEFT, LIDAR_SIDE_RIGHT, and LIDAR_BACK.

    (✓) indicates availability depends on whether the user opted-in during download (e.g., via include_cameras=true).

  5. Create conversion configurations for datasets

    main

    Conversion configurations are stored in src/py123d/script/config/conversion/dataset/ as <name>.yaml files. You should provide two distinct configuration files for each dataset:

    1. Local Config (<name>.yaml): Used when data is pre-downloaded. Roots point to local paths and sensors are typically stored as file paths.
    2. Stream Config (<name>-stream.yaml): Used for 'streaming during conversion'. Roots are set to null (auto-detected in a temp dir), a downloader block is included, and sensors are stored as binary data in temporary files that vanish after conversion.

    Each config contains four main sections:

    • parser: Instantiates your BaseDatasetParser via _target_ and defines data roots/splits.
    • log_writer_config: Configures storage options (e.g., camera_store_option, lidar_store_option, lidar_codec) and flags like async_conversion.
    • log_writer: Configures the ArrowLogWriter, including sync_config for timeline snapping.
    • map_writer: Configures the ArrowMapWriter.
  6. Understand the 123D Coordinate System

    main

    123D uses a right-handed coordinate system following the ISO 8855 ground vehicle standard. This convention applies to the ego vehicle, agents, and objects. All source datasets are converted to this unified system during conversion.

    AxisDirection
    XForward (longitudinal)
    YLeft (lateral)
    ZUp (vertical)
  7. Understand the 123D data structure

    main

    The 123D library converts driving datasets into a unified format consisting of Logs, Maps, and Sensors.

    Logs

    Each log is a directory containing:

    • Per-modality .arrow files (e.g., ego_state_se3.arrow, box_detections_se3.arrow, traffic_light_detections.arrow, camera.pcam_f0.arrow, lidar.lidar_merged.arrow).
    • A sync.arrow synchronization table.
    • Optional .mp4 files if MP4 camera compression is used.

    Maps

    Maps are stored as .arrow files and provide a unified HD-Map API. They can be defined:

    • Per-log: (e.g., in AV2 or Waymo datasets).
    • Globally: For specific locations (e.g., nuPlan, nuScenes, CARLA).

    Sensors

    Sensor data (Camera and Lidar) is handled in one of three ways:

    1. Relative Paths: Read from the original dataset via paths stored in the .arrow files.
    2. Embedded Binary: Data is embedded directly within the .arrow files.
    3. MP4 Compression: Camera data is stored as .mp4 files alongside the .arrow files in the log directory.
  8. Available sensor modalities in PandaSet

    main

    PandaSet provides multi-modal data including cameras, Lidars, and 3D bounding box annotations.

    Cameras

    PandaSet includes 6 cameras (via py123d.datatypes.CameraID):

    • PCAM_F0: front_camera
    • PCAM_L0: front_left_camera
    • PCAM_R0: front_right_camera
    • PCAM_L1: left_camera
    • PCAM_R1: right_camera
    • PCAM_B0: back_camera

    Lidars

    PandaSet includes 2 Lidars (via py123d.datatypes.LidarID):

    • LIDAR_TOP: main_pandar64
    • LIDAR_FRONT: front_gt

    Other Modalities

    • Ego Vehicle: Poses and vehicle parameters (see py123d.datatypes.EgoStateSE3).
    • Bounding Boxes: Available via py123d.parser.registry.PandasetBoxDetectionLabel (see py123d.datatypes.BoxDetectionsSE3).
  9. Rotation Conventions: Quaternions and Euler Angles

    main

    Quaternions

    123D uses unit quaternions (normalized to length 1) with a scalar-first convention. The identity rotation is (1, 0, 0, 0).

    ComponentIndexDescription
    $q_w$QuaternionIndex.QW (0)Scalar (real) part
    $q_x$QuaternionIndex.QX (1)Imaginary i component
    $q_y$QuaternionIndex.QY (2)Imaginary j component
    $q_z$QuaternionIndex.QZ (3)Imaginary k component

    Euler Angles

    123D follows the Tait-Bryan ZYX intrinsic convention (yaw $\rightarrow$ pitch $\rightarrow$ roll). Angles are always in radians and normalized to $[-\pi, \pi]$.

    ComponentIndexDescription
    RollEulerAnglesIndex.ROLL (0)Rotation around the X axis
    PitchEulerAnglesIndex.PITCH (1)Rotation around the Y axis
    YawEulerAnglesIndex.YAW (2)Rotation around the Z axis

    The combined rotation matrix is computed as: $R = R_z(\text{yaw}) \cdot R_y(\text{pitch}) \cdot R_x(\text{roll})$.

  10. How the 123D dataset conversion architecture works

    main

    The conversion pipeline is organized around three base classes defined in py123d.parser.base_dataset_parser.BaseDatasetParser.

    1. Dataset Parser: A top-level orchestrator that produces lightweight, picklable handles for logs and maps. It is instantiated once on the main process and distributed to parallel workers.
    2. Log Parser: A handle to a single continuous driving sequence (a 'log'). Workers use these to perform heavy I/O and yield synchronized frames.
    3. Map Parser: A handle to a specific map region.

    Data flows from these parsers into ArrowLogWriter and ArrowMapWriter, which store the results in Arrow format for access via the unified API.

    Important: Parsers must be lightweight. Do not store open file handles, database connections, or decoded sensor data in the parser classes. Store only paths and parameters; perform expensive I/O inside the iterators which run on the worker processes.

    BaseDatasetParser
      ├── get_log_parsers()  ──▶  [ LogParser_1, ..., LogParser_N ]  ──▶  ArrowLogWriter
      └── get_map_parsers()  ──▶  [ MapParser_1, ..., MapParser_M ]  ──▶  ArrowMapWriter
                                                                                │
                                                                                ▼
                                                                      Arrow storage ──▶ unified API
  11. Use lazy I/O for sensor data in LogParsers

    main

    To speed up conversion, you can avoid decoding heavy sensor data during parsing by using 'parsed' modality helpers. These carry only metadata and a reference to the data.

    Supported helpers:

    • ParsedCamera: Metadata, camera_to_global_se3 pose, and either a dataset_root/relative_path pair OR an in-memory byte_string.
    • ParsedLidar: Metadata, start_timestamp/end_timestamp (sweep window), dataset_root/relative_path, and optional load_kwargs.
    • ParsedRadar: Metadata, timestamp, file path, and optional load_kwargs.

    If sensor storage is configured as "path", the conversion is much faster but the resulting logs are not self-contained (they require the original files).

  12. Understand the two variants of transformation functions

    main

    The py123d geometry module provides two distinct ways to perform coordinate-frame transformations for SE(2) and SE(3) poses and points. Depending on your data format, you should choose between:

    1. Typed functions (no suffix): These functions are designed for high-level geometry objects. They accept and return specific typed objects such as PoseSE2, PoseSE3, Point2D, and Point3D. Use these when working with the library's primary geometric abstractions.
    2. Array functions (suffix _array): These functions operate directly on raw NumPy arrays. They are optimized for performance and support batch dimensions, making them ideal for processing large datasets or vectorized operations.