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 Crosswalks Tool

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

Overview

Command-line utility script that visualizes all crosswalk locations on the current CARLA map by drawing indexed labels and connected line segments.

Description

This script (show_crosswalks.py) retrieves all crosswalk vertices from the current map using tmap.get_crosswalks() and draws them in the simulation viewport. It includes a get_traffic_light_bbs() helper function for computing traffic light bounding boxes (shared utility across several visualization scripts). The main visualization draws index labels at each crosswalk vertex using world.debug.draw_string() and connects every group of 5 consecutive vertices with dark blue lines (Color(0,0,128)) using world.debug.draw_line() with configurable lifetime via the --show argument. The crosswalk vertices are elevated by 0.5 or 1.0 units on the z-axis for visibility above the road surface.

Usage

Use this tool to inspect and verify crosswalk placement in a CARLA map, which is useful for pedestrian simulation testing, map validation, and debugging OpenDRIVE crosswalk definitions.

Code Reference

Source Location

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

Signature

def get_traffic_light_bbs(traffic_light):
    """Compute bounding box and trigger volume for a traffic light."""

def main():
    """Retrieve and visualize all crosswalk vertices in the scene."""

Import

# Run as a command-line tool:
python show_crosswalks.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
Vertex labels Black text Index number at each crosswalk vertex
Connecting lines Dark blue (0,0,128) Lines connecting groups of 5 vertices

Usage Examples

# Visualize crosswalks for 100 seconds (default)
python show_crosswalks.py

# Visualize crosswalks for 300 seconds
python show_crosswalks.py --show 300

# Connect to a remote server
python show_crosswalks.py --host 192.168.1.100 -p 2000 --show 60

Related Pages

Page Connections

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