Implementation:CARLA simulator Carla Show Topology Tool
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Visualization, Utility |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
Command-line utility script that visualizes the complete road topology of the current CARLA map by drawing arrows along waypoints from entry to exit for every road segment.
Description
This script (show_topology.py) renders the entire road network topology using debug drawing. It retrieves the map topology via tmap.get_topology() and iterates through each (entry_wp, exit_wp) pair. For each segment, it samples waypoints at a resolution of 5 meters using waypoint.next(), drawing arrows between consecutive waypoints. Road segments outside junctions are drawn in dark blue (Color(0,0,128)), while junction segments are drawn in green (Color(0,128,0)). The script calls world.wait_for_tick() between segments to prevent overloading the debug drawing system. All arrows are drawn 0.5 units above ground level for visibility, with configurable display duration via --show. The get_traffic_light_bbs() helper function is also included for computing traffic light bounding boxes.
Usage
Use this tool to visualize and verify the road network topology of a CARLA map, particularly useful for identifying connectivity issues, verifying junction definitions, and understanding road segment structure.
Code Reference
Source Location
- Repository: CARLA
- File: PythonAPI/util/show_topology.py
Signature
def get_traffic_light_bbs(traffic_light):
"""Compute bounding box and trigger volume for a traffic light."""
def main():
"""Visualize road topology with sampled waypoint arrows."""
# sampling_resolution = 5
# Blue arrows for roads, green for junctions
Import
# Run as a command-line tool:
python show_topology.py --show 100
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 |
| --show | float | 100 | Duration of the visualization in seconds |
| Visual Element | Color | Description |
|---|---|---|
| Road segment arrows | Dark blue (0,0,128) | Non-junction road waypoint connections |
| Junction segment arrows | Green (0,128,0) | Junction waypoint connections |
Usage Examples
# Visualize topology for 100 seconds (default)
python show_topology.py
# Extended visualization
python show_topology.py --show 500
# Remote server
python show_topology.py --host 192.168.1.100 -p 2000