Justin900429
carla2cosmos
Python

Toolkit to transfer the carla format to cosmos RDS-HQ

Last updated Aug 3, 2026
15
Stars
0
Forks
0
Issues
0
Stars/day
Attention Score
1
Language breakdown
Python 100.0%
โ–ธ Files click to expand
README

๐Ÿš— Carla2Cosmos

This repository provides a toolkit for converting CARLA simulation data to the RDS-HQ format used by Cosmos. The converted data can be used with Cosmos Sample AV Transfer to generate real-world videos with similar traffic scenarios.

>[!CAUTION]

This repository DOES NOT perform direct style transfer from CARLA to real-world video. Instead, it extracts interactive data like bounding boxes and LiDAR points to help generate real-world videos containing similar traffic scenes and behaviors.

| HD Map | Lidar | Generate Output | | ------ | ----- | --------------- | |HD Map | lidar | output |

Prompt

The video is captured from a camera mounted on a car. The camera is facing forward. The video showcases a scenic golden-hour drive through a suburban area, bathed in the warm, golden hues of the setting sun. The dashboard camera captures the play of light and shadow as the sunโ€™s rays filter through the trees, casting elongated patterns onto the road. The streetlights remain off, as the golden glow of the late afternoon sun provides ample illumination. The two-lane road appears to shimmer under the soft light, while the concrete barrier on the left side of the road reflects subtle warm tones. The stone wall on the right, adorned with lush greenery, stands out vibrantly under the golden light, with the palm trees swaying gently in the evening breeze. The golden light, combined with the quiet suburban landscape, creates an atmosphere of tranquility and warmth, making for a mesmerizing and soothing drive.

โ–ถ๏ธ Recording a Clip

Stream and record synchronous CARLA sessions at 30โ€ฏHz, saving only the essential data needed to convert each clip into the RDS-HQ format (used by Cosmos-AV). To record the data, run the stream_carla.py script to begin recording:

python stream_carla.py \
  --town {TOWN_NAME} \
  --numframes {NUMFRAMES} \
  --outdir {DIRFORSAVINGDATA}

for example

python stream_carla.py \ --town Town04 \ --num_frames 600 \ --out_dir ./data \

This will create a 600-frame clip inside ./data/clip_001. Each recording is saved under:

<outdir>/clip<clip_id>/
โ”œโ”€โ”€ ego_pose/              # 4ร—4 SE(3) worldโ†ego transforms (NumPy .npy)
โ”œโ”€โ”€ lidar/                 # LiDAR point clouds with intensity (NumPy .npz)
โ”œโ”€โ”€ camera_front/          # RGB camera frames (PNG images)
โ”œโ”€โ”€ labels_3d/             # 3D dynamic object bounding boxes (JSON)
โ”œโ”€โ”€ hdmap/static_map.xodr  # OpenDRIVE static HD map
โ”œโ”€โ”€ calibration/           # Sensor calibration files (lidar.json, camera_front.json)
โ”œโ”€โ”€ timestamp.json         # Frame timestamps in seconds
โ”œโ”€โ”€ record.log             # Log file of the recording session
โ””โ”€โ”€ camerafront.mp4       # (Optional) Rendered video if --makevideo is used

Note that:

  • only three blobs are written per frame โ€” the rest are static across the clip.
  • All coordinates follow the right-handed ENU convention (like Waymo & RDS-HQ).
>[!TIP]
Run python stream_carla.py --help to see all available configuration options, including sensor settings, simulation parameters, and output preferences.

๐Ÿ—ƒ๏ธ Converting to RDS-HQ

To convert the recorded data to the RDS-HQ format, run the converttords_hq.py script:

export PYTHONPATH=$PYTHONPATH:$(pwd)

python toolkit/convertcarlatordshq.py \ --root-dir {DIRWITHRECORDING_CLIPS} \ --out-dir {DIRFORSAVING_DATA}

for example

python toolkit/convertcarlatordshq.py \ --root-dir data \ --out-dir outputs

This will create a directory with the following structure:

<out_dir>/
โ”œโ”€โ”€ pinhole_front/        # Contains video files (.mp4)
โ”œโ”€โ”€ pinhole_intrinsic/    # Contains camera intrinsic parameters
โ”œโ”€โ”€ lidar_raw/            # Contains LiDAR data archives (.tar)
โ”œโ”€โ”€ allobjectinfo/      # Contains object information data
โ”œโ”€โ”€ timestamp/            # Contains timestamp data
โ”œโ”€โ”€ vehicle_pose/         # Contains vehicle pose data
โ”œโ”€โ”€ pose/                 # Contains pose data
โ”œโ”€โ”€ 3droadboundaries/   # Contains 3D road boundary data
โ”œโ”€โ”€ 3d_lanelines/         # Contains 3D lane line data
โ””โ”€โ”€ 3d_lanes/             # Contains 3D lane data

To visualize the converted data:

python toolkit/visualizerdshq.py \
  -i {DIRFORSAVING_DATA} \
  -c {CLIP_ID} \
  -d carla

for example

python toolkit/visualizerdshq.py \ -i outputs \ -c 0000 \ -d carla

๐ŸŽฅ Rendering from RDS-HQ

>[!TIP]

The rendering functionality is based on the cosmos-av-sample-toolkits repository. You can refer to their documentation for more details about the rendering process and options.

To render the HD-Map and Lidar from the RDS-HQ format, run the renderrdshq.py script:

export PYTHONPATH=$PYTHONPATH:$(pwd)

python toolkit/renderrdshq.py \ -d carla \ -i {DIRWITHRDSHQDATA} \ -o {DIRFORSAVINGRENDEREDDATA} \ -c ftheta # recommend

for example

python toolkit/renderrdshq.py \ -d carla -i outputs \ -o demo_render -c ftheta # recommend

This will create a directory with the following structure:

<render_dir>/
demo_render/
โ”œโ”€โ”€ lidar/
โ”‚   โ””โ”€โ”€ pinhole_front/    # Contains LiDAR visualization data
โ””โ”€โ”€ hdmap/
    โ””โ”€โ”€ pinhole_front/    # Contains HD map visualization data

For multi-camera setups, rendered data is organized in the lidar and hdmap directories with the naming convention pinhole<cameraname>.

>[!Note]

The current version only supports rendering from the front camera.

๐Ÿ“ Development

Please refer to the Development for more details.

๐Ÿ”’ Immunity

All outputs generated by this system, including but not limited to:

  • Recorded data
  • Rendered visualizations
  • Converted formats
  • Derived analytics
are provided for research and educational purposes only. Users are responsible for:
  • Verifying the accuracy and suitability of generated outputs for their specific use case
  • Ensuring compliance with local laws and regulations when using the outputs
  • Obtaining necessary permissions for any commercial or public use
  • Acknowledging that the outputs may not be suitable for safety-critical applications
By using this software, you agree to indemnify and hold harmless the developers and contributors from any claims, damages, or liabilities arising from the use of the models or generated outputs.
๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท Justin900429/carla2cosmos ยท Updated daily from GitHub