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 Python Module Entry

From Leeroopedia
Knowledge Sources
Domains Python Bindings, Module Initialization
Last Updated 2026-02-15 05:00 GMT

Overview

The top-level Boost.Python module entry point that defines the carla Python module and orchestrates initialization of all binding submodules.

Description

This file contains the BOOST_PYTHON_MODULE(carla) macro invocation that defines the carla Python extension module. It declares external references to all export_* functions and calls them in sequence during module initialization: export_geom, export_control, export_blueprint, export_actor, export_sensor, export_sensor_data, export_snapshot, export_weather, export_world, export_map, export_client, export_exception, export_commands, export_trafficmanager, and export_lightmanager. Conditional compilation guards include export_ad_rss (when LIBCARLA_RSS_ENABLED) and export_osm2odr (when CARLA_PYTHON_API_HAS_OSM2ODR). For Python versions below 3.7, PyEval_InitThreads() is called for thread safety.

Usage

This file is compiled into the shared library that Python loads when import carla is executed. It is the single entry point that ties all binding modules together into one cohesive Python package.

Code Reference

Source Location

  • Repository: CARLA
  • File: PythonAPI/carla/src/PythonAPI.cpp

Signature

BOOST_PYTHON_MODULE(carla) {
    export_geom();
    export_control();
    export_blueprint();
    export_actor();
    export_sensor();
    export_sensor_data();
    export_snapshot();
    export_weather();
    export_world();
    export_map();
    export_client();
    export_exception();
    export_commands();
    export_trafficmanager();
    export_lightmanager();
#ifdef LIBCARLA_RSS_ENABLED
    export_ad_rss();
#endif
#ifdef CARLA_PYTHON_API_HAS_OSM2ODR
    export_osm2odr();
#endif
}

Import

import carla

I/O Contract

Inputs

Name Type Required Description
(none) - - Module is loaded automatically on import

Outputs

Name Type Description
carla module Python module Fully initialized carla namespace with all subclasses

Usage Examples

# The entire CARLA Python API is available after this import
import carla

# All bound classes are now accessible
client = carla.Client('localhost', 2000)
location = carla.Location(x=0, y=0, z=0)
transform = carla.Transform()

Related Pages

Page Connections

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