This guide covers installation, usage, and common workflows for CARLA Dataset Tools.
- Prerequisites
- Installation
- Quick Start
- Route Editor
- Configuration Profiles
- Recording Data
- Generating Labels
- Visualization
- Data Format
- Troubleshooting
Before you begin, ensure you have the following:
- CARLA Simulator >= 0.9.16
- Python >= 3.8
- CARLA Python API (included with CARLA distribution)
- Operating System: Linux (recommended) / Windows
Download CARLA: https://github.com/carla-simulator/carla/releases
git clone https://github.com/KevinLADLee/carla_dataset_tools.git
cd carla_dataset_toolspip3 install -r requirements.txtRequired packages:
- opencv-python > 4.0
- carla >= 0.9.16
- numpy < 2.0, >= 1.24.4
- transforms3d ~= 0.4.2
- open3d
- pandas
- shapely
- networkx
- pyyaml >= 6.0
Add the following to your ~/.bashrc or ~/.zshrc:
# Set CARLA root directory
export CARLA_ROOT=/path/to/your/carlaReplace /path/to/your/carla with your actual CARLA installation path.
Then reload your shell configuration:
source ~/.bashrc # or source ~/.zshrcpython3 -c "import carla; print(f'CARLA version: {carla.__version__}')"If you see the CARLA version printed, installation is successful!
First, launch the CARLA server:
cd $CARLA_ROOT
./CarlaUE4.shFor headless mode (no rendering):
./CarlaUE4.sh -RenderOffScreenRun the data recorder with a configuration profile:
# Use default configuration profile
python3 data_recorder.py
# Use KITTI-style configuration
python3 data_recorder.py --profile kitti
# Use Argoverse-style configuration
python3 data_recorder.py --profile argoverse
# Use simple configuration for testing
python3 data_recorder.py --profile simple
# Use custom YAML configuration file
python3 data_recorder.py --config my_custom_config.yamlControl Options:
- The recorder will automatically collect data until the configured frame count is reached
- Press
Ctrl+Cto stop recording manually
Output Location:
Data will be saved to: raw_data/record_YYYY_MMDD_HHMM/
After recording, generate labels in your desired format:
python3 label_tools/kitti_objects_label.py -r record_2022_0119_1303Options:
# Specify vehicle
python3 label_tools/kitti_objects_label.py -r record_2022_0119_1303 -v vehicle.tesla.model3_1
# Specify sensors
python3 label_tools/kitti_objects_label.py -r record_2022_0119_1303 -l velodyne -c image_2
# Custom output directory
python3 label_tools/kitti_objects_label.py -r record_2022_0119_1303 -o my_datasetpython3 label_tools/yolo_label.py -r record_2022_0119_1303python3 label_tools/argoverse_label.py -r record_2022_0119_1303The Route Editor is an interactive tool for creating custom vehicle routes. It allows you to visually define waypoints on the map, and the system automatically calculates road-topology-aware paths for realistic vehicle navigation.
- Precise Control: Define exact paths for vehicles to follow during data collection
- Loop Routes: Create circular routes for continuous data recording
- Visual Feedback: See the actual road path vehicles will take (not just straight lines)
- Topology-Aware: Routes follow real road networks, lanes, and intersections
1. Launch Route Editor
Make sure CARLA server is running, then:
python3 tools/editor_route.py --map Town02 --name my_route2. Create Your Route
- Left Click: Add waypoint (can click same location multiple times)
- Right Click on Circle: Delete waypoint
- Ctrl+Z: Undo last waypoint
- Enter: Save and exit
- Escape: Cancel
3. Visual Elements
- Red Circles: Your selected waypoints
- Lime Green Path: Actual road path vehicle will follow (topology-aware)
- Blue Dashed Line: Direct connections between waypoints (reference)
- Status Counter: Bottom-right shows waypoint count and loop status
To create a loop route, simply make your last waypoint close to your first waypoint (within 5 meters). The system will automatically:
- Detect the loop
- Show
[LOOP DETECTED]in the window title - Draw the return path from last to first waypoint
After creating a route, use it in your YAML configuration:
Method 1: Load from File
actors:
- type: vehicle.tesla.model3
name: vehicle_1st
spawn_point: 73
route:
from_file: routes/Town02_my_route.yaml
sensors: [...]Method 2: Inline Waypoints
actors:
- type: vehicle.tesla.model3
name: vehicle_1st
spawn_point: 73
route:
mode: strict
loop: true # Optional: for loop routes
waypoints:
- {x: 107.5, y: -133.2, z: 0.3}
- {x: 150.0, y: -130.5, z: 0.3}
- {x: 200.3, y: -128.8, z: 0.3}
sensors: [...]strict: Vehicle strictly follows waypoint sequence using road topologydisabled: Ignores route, uses default CARLA autopilot- No route specified: Default autopilot behavior (backward compatible)
- User Input: You specify 3-8 key waypoints
- Path Planning: GlobalRoutePlanner calculates complete road path between each waypoint pair
- Expansion: Your 8 waypoints → 450+ road waypoints following lanes/intersections
- Navigation: BasicAgent guides vehicle along the complete path
Example Console Output:
Vehicle 'vehicle_1st' configured with route: 8 waypoints
expanded to 453 road waypoints following topology (LOOP)
- For Loop Routes: Click near the start point at the end (within 5m radius)
- Waypoint Placement: Waypoints represent "must pass through" locations, not every turn
- Road Snapping: Waypoints automatically snap to nearest valid road position
- Topology Preview: Green path shows exactly what vehicle will drive
- Testing: Use
--profile route_exampleto see a complete working example
# 1. Start CARLA
cd $CARLA_ROOT && ./CarlaUE4.sh
# 2. Create route (in another terminal)
python3 tools/editor_route.py --map Town02 --name downtown_loop
# 3. Click waypoints on the map
# 4. Press Enter to save
# 5. Use the route in recording
python3 data_recorder.py --profile route_exampleSaved routes are stored in routes/ directory as both YAML (human-readable) and PKL (internal) formats.
The toolkit includes several pre-configured profiles located in config/profiles/:
default- General purpose configuration with multiple vehicles and sensorskitti- KITTI-style dataset configuration (Velodyne HDL-64E, standard cameras)argoverse- Argoverse-style with ring cameras and stereo setupsimple- Minimal configuration for quick testing
# List available profiles
python3 tools/config_list.py
# Validate a profile
python3 tools/config_validate.py --profile kitti
# Use a profile for recording
python3 data_recorder.py --profile kitti-
Copy an existing profile:
cp config/profiles/default.yaml config/profiles/my_config.yaml
-
Edit the configuration:
- Modify sensor parameters, vehicle types, spawn points
- YAML supports comments for documentation
- Use YAML anchors (
&and*) to reuse configurations
-
Validate your configuration:
python3 tools/config_validate.py config/profiles/my_config.yaml
-
Use your configuration:
python3 data_recorder.py --config config/profiles/my_config.yaml
- Start CARLA server - Launch the simulator
- Choose configuration - Select or create a profile
- Run recorder - Execute
data_recorder.pywith your chosen profile - Monitor progress - Watch console output for frame progress
- Stop recording - Wait for completion or press
Ctrl+C
Configure these in your YAML profile:
recording:
frame_total: 12000 # Total frames to record
frame_step: 3 # Save every N frames
map: Town02 # CARLA map name
weather: ClearNoon # Weather preset (optional)Configure multiple vehicles in the actors section:
actors:
- type: vehicle.tesla.model3
name: ego_vehicle
spawn_point: 73
sensors: [...]
- type: vehicle.audi.a2
name: following_vehicle
spawn_point: 76
sensors: [...]The KITTI labeling tool converts raw data into KITTI object detection format:
python3 label_tools/kitti_objects_label.py -r <record_name> [options]Common Options:
-r, --record- Record folder name (required)-v, --vehicle- Specific vehicle to process-l, --lidar- LiDAR sensor name (default: velodyne)-c, --camera- Camera sensor name (default: image_2)-o, --output- Output directory name
Output Structure:
dataset/record_YYYY_MMDD_HHMM/vehicle_name/kitti_object/
├── ImageSets/
│ ├── train.txt
│ └── val.txt
└── training/
├── calib/ # Calibration files
├── image_2/ # RGB images
├── label_2/ # 3D bounding box labels
└── velodyne/ # Point clouds (.bin)
Generate 2D bounding box labels for YOLOv5:
python3 label_tools/yolo_label.py -r <record_name>Output includes:
- Images in YOLO format
- Label text files (class x_center y_center width height)
- Dataset configuration file
Before recording, you can visualize your configuration to verify the actor hierarchy is correct:
# Visualize default profile
python3 tools/viz_actor_tree.py default
# Visualize custom configuration
python3 tools/viz_actor_tree.py my_config.yaml
# Generate SVG format
python3 tools/viz_actor_tree.py simple --format svg --output my_tree
# Generate PDF format
python3 tools/viz_actor_tree.py argoverse --format pdf
# Auto-open after generation
python3 tools/viz_actor_tree.py default --view
# List available profiles
python3 tools/viz_actor_tree.py --listFeatures:
- No CARLA Required: Visualizes directly from configuration file
- Complete Information: Shows vehicles, sensors, spawn points, sensor parameters, routes
- Color Coding: Different colors for different node types (vehicles, sensors, infrastructure)
- Multiple Formats: PNG (default), SVG, PDF
- Statistics Summary: Total actors, sensors, background vehicles
Output: The tool generates a graphical tree showing:
- Configuration summary (map, frames, delta time)
- World node with all actors
- Each vehicle/infrastructure with its sensors
- Sensor parameters (resolution, FOV, range, etc.)
- Spawn points and coordinates
- Route information (waypoint count, mode)
Dependencies:
# Install required package
pip install graphviz
# Install system graphviz (if needed)
# Ubuntu/Debian:
sudo apt-get install graphviz
# macOS:
brew install graphviz# Visualize a single file
python3 tools/viz_lidar.py --type lidar --source raw_data/record_2022_0119_1303/vehicle.tesla.model3_1/000001_lidar.npy
# Visualize all frames (glob mode)
python3 tools/viz_lidar.py --type lidar --source raw_data/record_2022_0119_1303/vehicle.tesla.model3_1/Supported types:
lidar- Standard LiDAR point cloudsemantic_lidar- Semantic LiDAR with class labelsradar- Radar detection points
Visualization Controls:
- Mouse: Rotate and zoom
- Arrow keys: Navigate between frames (glob mode)
Q: Quit visualization
raw_data/
└── record_YYYY_MMDD_HHMM/
├── carla_raw_record.log # CARLA recorder log
├── dataset_info.json # Dataset metadata
├── master_index.csv # Global frame index
├── vehicle.tesla.model3_1/
│ ├── 000001_image_2.png # RGB images
│ ├── 000001_image_2_semantic.png
│ ├── 000001_velodyne.npy # LiDAR (Nx4: x,y,z,intensity)
│ ├── 000001_velodyne_semantic.npy
│ ├── 000001_radar_front.npy
│ ├── sensor_index.csv # Per-actor sensor index
│ ├── image_2/
│ │ └── poses.csv # Camera poses
│ ├── velodyne/
│ │ └── poses.csv # LiDAR poses
│ ├── sensor_data.csv # [Legacy] Sensor poses
│ └── vehicle_data.csv # Vehicle state
└── others.world_0/
├── 000001_objects.pkl # Object labels
└── objects_index.csv # World objects index
Index Files (automatically generated):
dataset_info.json- Dataset metadata (map, weather, sensors, frame rate)master_index.csv- Global frame-level index with data availability flagssensor_index.csv- Per-vehicle sensor data index with file pathsobjects_index.csv- World objects index with object counts{sensor_name}/poses.csv- Per-sensor pose data (transform, rotation)
dataset/
└── record_YYYY_MMDD_HHMM/
└── vehicle.tesla.model3_1/
└── kitti_object/
├── ImageSets/
│ ├── train.txt
│ └── val.txt
└── training/
├── calib/ # Calibration files
├── image_2/ # RGB images
├── label_2/ # 3D bounding box labels
└── velodyne/ # Point clouds (.bin)
Important: All raw data uses a right-hand coordinate system:
- X: Forward
- Y: Right
- Z: Up
KITTI Format: Uses camera coordinate system (X: right, Y: down, Z: forward)
Transformation: Automatic conversion happens during the labeling process.
- Images: PNG format (RGB, semantic segmentation)
- LiDAR: NumPy
.npyfiles (Nx4: x, y, z, intensity) - Semantic LiDAR: NumPy
.npyfiles (Nx6: x, y, z, cos_angle, object_idx, tag) - Radar: NumPy
.npyfiles (Nx4: x, y, z, velocity) - Labels: Pickle
.pklfiles (raw) or text files (KITTI/YOLO)
Solution:
- Verify CARLA_ROOT is set:
echo $CARLA_ROOT - Check the CARLA Python API is accessible
- Ensure the .egg file matches your Python version
Solution:
- Ensure CARLA server is running:
./CarlaUE4.sh - Check the port (default: 2000):
python3 data_recorder.py -p 2000 - Verify firewall settings allow connection
- Try connecting to a different host:
python3 data_recorder.py --host localhost
Solution:
- Reduce sensor count in configuration
- Lower sensor resolution (image_size_x, image_size_y)
- Increase frame_step to skip frames
- Use headless mode:
./CarlaUE4.sh -RenderOffScreen - Reduce background traffic (other_vehicles count)
Solution:
pip3 install "numpy>=1.24.4,<2.0"Solution:
- Check YAML syntax is valid
- Ensure all required fields are present
- Validate sensor types match CARLA 0.9.16 API
- Use validation tool:
python3 tools/config_validate.py --profile <name>
Solution:
- Change spawn points in configuration
- Reduce number of vehicles
- Use different map with more spawn points
- Use
tools/debug_info.pyto discover valid positions
Solution:
- Check sensor is properly configured in YAML
- Verify sensor name matches in configuration
- Ensure sufficient disk space for data
- Check console output for sensor errors
If you encounter issues not covered here:
- GitHub Issues: https://github.com/KevinLADLee/carla_dataset_tools/issues
- CARLA Documentation: https://carla.readthedocs.io/
- Developer Guide: See DEVELOPER.md for advanced topics