Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CARLA simulator Carla Show Traffic Lights Tool

From Leeroopedia
Knowledge Sources
Domains Simulation, Visualization, Utility
Last Updated 2026-02-15 05:00 GMT

Overview

Command-line utility script that visualizes comprehensive traffic light information in a CARLA simulation, including bounding boxes, trigger volumes, light boxes, affected waypoints, and stop waypoints.

Description

This script (show_traffic_lights.py) provides the most detailed traffic light visualization in the CARLA utility suite. It discovers all traffic lights by scanning junctions from the map topology, then for each traffic light renders: a blue bounding box (Color(0,0,200)) around the physical structure, a green trigger volume (Color(0,200,0)) showing the detection area, red light boxes (Color(200,0,0)) for individual signal heads, pink arrows and points (Color(200,0,200)) for affected lane waypoints, and teal arrows and points (Color(0,200,200)) for stop waypoints. Text labels show the pole index and OpenDRIVE ID. The get_traffic_light_bbs() helper function computes world-space bounding boxes by applying rotation transforms from the traffic light's base transform.

Usage

Use this tool for comprehensive traffic light inspection, verifying trigger volume placement, confirming affected lane assignments, and debugging traffic light behavior in CARLA maps.

Code Reference

Source Location

  • Repository: CARLA
  • File: PythonAPI/util/show_traffic_lights.py

Signature

def get_traffic_light_bbs(traffic_light):
    """Compute world-space bounding box and trigger volume."""
    # Returns (bounding_box, trigger_volume) as carla.BoundingBox

def main():
    """Discover and visualize all traffic light data."""
    # Renders: bounding boxes, trigger volumes, light boxes,
    # affected waypoints, stop waypoints, pole index, OpenDrive ID

Import

# Run as a command-line tool:
python show_traffic_lights.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
Bounding box Blue (0,0,200) Physical traffic light structure bounds
Trigger volume Green (0,200,0) Vehicle detection area
Light boxes Red (200,0,0) Individual signal head positions
Affected waypoints Pink (200,0,200) Lanes controlled by this traffic light
Stop waypoints Teal (0,200,200) Stop line positions
Labels Dark blue (0,0,128) Pole index and OpenDRIVE ID text

Usage Examples

# Visualize all traffic light data for 100 seconds
python show_traffic_lights.py

# Extended visualization
python show_traffic_lights.py --show 300

# Remote server
python show_traffic_lights.py --host 192.168.1.100 --show 60

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment