Implementation:CARLA simulator Carla Extract Spawn Points Tool
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Map Management, Utility |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
Command-line utility script that extracts and exports all spawn points from the current CARLA map, optionally visualizing them in the simulation and saving to a CSV file.
Description
This script (extract_spawn_points.py) retrieves all available spawn points from the current map using tmap.get_spawn_points(). It supports two modes of operation: visualization mode (--show) draws colored points and index labels at each spawn point location in the simulation using world.debug.draw_point() and world.debug.draw_string(), and export mode (-o/--output-dir) writes all spawn points to a CSV file named spawn_points.csv with columns for index, x, y, z, roll, pitch, and yaw. The visualization uses dark blue points (Color(0,0,128)) with black text labels showing the spawn point index.
Usage
Use this tool to explore and document spawn point locations on a CARLA map. The exported CSV is useful for custom traffic generation scripts or analyzing spawn point distributions.
Code Reference
Source Location
- Repository: CARLA
- File: PythonAPI/util/extract_spawn_points.py
Signature
def main():
"""Extract, visualize, and/or export spawn points."""
# Connects to CARLA, retrieves spawn points
# Optionally visualizes with debug drawing
# Optionally saves to CSV file
Import
# Run as a command-line tool:
python extract_spawn_points.py --show -o /path/to/output/
I/O Contract
| Argument | Type | Default | Description |
|---|---|---|---|
| --host | str | 127.0.0.1 | CARLA server IP address |
| -p, --port | int | 2000 | CARLA server TCP port |
| -o, --output-dir | str | Directory to save spawn_points.csv | |
| --show | flag | False | Visualize spawn points in the simulation |
| Output File | Format | Columns |
|---|---|---|
| spawn_points.csv | CSV | index, x, y, z, roll, pitch, yaw |
Usage Examples
# Visualize all spawn points in the scene
python extract_spawn_points.py --show
# Export spawn points to CSV
python extract_spawn_points.py -o /tmp/spawn_data/
# Both visualize and export
python extract_spawn_points.py --show -o /tmp/spawn_data/