Implementation:CARLA simulator Carla Python Blueprint Bindings
| Knowledge Sources | |
|---|---|
| Domains | Python Bindings, Actor Blueprints |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
Boost.Python binding file that exposes the blueprint system (ActorBlueprint, BlueprintLibrary, ActorAttribute, Color) to the CARLA Python API.
Description
This file defines the export_blueprint() function that registers CARLA's blueprint-related C++ classes with Boost.Python. It exposes the ActorAttributeType enumeration (Bool, Int, Float, String, RGBColor), the Color class with RGBA components, FloatColor for floating-point colors, OpticalFlowPixel for optical flow data, ActorAttribute with type conversion methods (as_bool, as_int, as_float, as_str, as_color) and comparison operators, ActorBlueprint with tag matching (has_tag, match_tags) and attribute access (has_attribute, get_attribute, set_attribute), and BlueprintLibrary with filtering capabilities (find, filter, filter_by_attribute). The BlueprintLibrary supports Python iteration and indexing protocols.
Usage
This binding is used whenever a Python script needs to discover, filter, or configure actor blueprints before spawning actors in the simulation. It is the entry point for selecting vehicle models, sensor types, and other actor templates.
Code Reference
Source Location
- Repository: CARLA
- File: PythonAPI/carla/src/Blueprint.cpp
Signature
void export_blueprint();
// Key classes exposed:
class_<cc::ActorAttribute>("ActorAttribute", no_init)
class_<cc::ActorBlueprint>("ActorBlueprint", no_init)
class_<cc::BlueprintLibrary>("BlueprintLibrary", no_init)
class_<csd::Color>("Color")
class_<crpc::FloatColor>("FloatColor")
Import
import carla
bp_library = world.get_blueprint_library()
bp = bp_library.find('vehicle.tesla.model3')
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| id | str | Yes (for find) | Blueprint identifier string |
| wildcard_pattern | str | Yes (for filter) | Wildcard pattern to filter blueprints |
| name | str | Yes (for set_attribute) | Attribute name to set |
| value | str | Yes (for set_attribute) | Attribute value to set |
Outputs
| Name | Type | Description |
|---|---|---|
| blueprint | carla.ActorBlueprint | A single blueprint matching the query |
| filtered_library | carla.BlueprintLibrary | Subset of blueprints matching filter |
| attribute | carla.ActorAttribute | Attribute value with type info |
Usage Examples
import carla
client = carla.Client('localhost', 2000)
world = client.get_world()
bp_library = world.get_blueprint_library()
# Filter for all vehicles
vehicles = bp_library.filter('vehicle.*')
# Find a specific blueprint
bp = bp_library.find('vehicle.lincoln.mkz_2017')
# Set attributes
if bp.has_attribute('color'):
bp.set_attribute('color', '255,0,0')
# Iterate over all blueprints
for bp in bp_library:
print(bp.id, bp.tags)