Skip to main content

CarlaBEV

A lightweight bird’s-eye-view driving simulator for reinforcement-learning research, with a Gymnasium API, procedural traffic, and repeatable scenarios on Town01. It uses simplified vehicle dynamics for fast experimentation.

CarlaBEV random traffic rendered at 512 × 512

Random Town01 traffic, rendered at 512 × 512: ego in cyan, traffic in blue, and route checkpoints in green.

Install and run

Requires Python 3.12 or newer. Once the first PyPI release is available, install it in your Python environment:

python -m pip install carlabev
carlabev run sim --size 512

In the meantime, you can install the current GitHub version with pip:

python -m pip install "carlabev @ git+https://github.com/danielmtzbarba/carlabev-env.git"

For development, use a checkout and uv:

git clone https://github.com/danielmtzbarba/carlabev-env.git
cd carlabev-env
uv sync
bash scripts/setup-hooks.sh

The pre-push hook checks Ruff lint, Ruff formatting, and pytest using the locked development dependencies. GitHub Actions repeats those checks on pull requests and pushes to main.

Drive with the arrow keys and press Q to quit. For a smoother display:

carlabev run sim --size 512 --display-fps 60

Run headless episodes or change traffic difficulty:

carlabev run sim --control random --episodes 5
carlabev run sim --size 512 --difficulty-preset-id hard --seed 1

Settings

Option Purpose
--size 256 or --size 512 Native raster resolution; the physical field of view stays the same.
--control manual|random|idle|forward Select keyboard or automatic actions.
--difficulty-preset-id easy|medium|hard Choose random-scene traffic difficulty.
--physics-dt 0.05 Set physics time per substep, in seconds; default is 0.1.
--action-repeat 2 Hold each action for two physics substeps.
--seed 5 Set the base scene seed.
--record-video runs/videos Record episode videos.

--display-fps changes presentation, and --physics-dt changes simulation time. Use carlabev run sim --help for all options. See the configuration reference for Python configuration. In a development checkout, prefix CLI commands with uv run.

Features

  • Gymnasium environments with discrete or continuous ego actions.
  • RGB and semantic BEV observations, frame stacking, and direct vector observations.
  • Random traffic with car following, signals, junction yielding, and vehicle recycling.
  • Authored scenes and lead_brake, jaywalk, and red_light_runner scenarios.
  • Metric actor footprints, collision detection, and curvature-aware NPC speed control.
  • Seeded scene generation, cached scene libraries, and replay validation.

Train a DRL agent

Use CarlaBEV through Gymnasium’s reset() and step() API. The environment factory adds observation resizing, semantic masks, frame stacking, and episode statistics:

from CarlaBEV.config import EnvConfig, RunConfig
from CarlaBEV.envs import make_env

envs = make_env(RunConfig(
    num_envs=8,
    env=EnvConfig(render_mode="rgb_array", obs_mode="bev_semantic"),
))
observations, info = envs.reset(seed=42)
try:
    for _ in range(1_000):
        actions = envs.action_space.sample()  # Replace with policy(observations).
        next_observations, rewards, terminated, truncated, info = envs.step(actions)
        # Store the transition and update your DRL algorithm here, before resets.
        observations = next_observations
        done = terminated | truncated
        if done.any():
            observations, info = envs.reset(options={"reset_mask": done})
finally:
    envs.close()

The example samples random actions; replace that line with your policy. Actions and transitions are batched across environments. Autoreset is disabled, so reset completed environments using reset_mask. Keep terminated and truncated separate when computing learning targets. See the training integration contract for details.

Architecture

CarlaBEV systems and DRL interaction

The simulation advances on an explicit clock. Rendering observes its state and does not control physics timing.

Documentation · Python integration · Scenarios · Diagnostics and validation

Original software and documentation are licensed under Apache-2.0. Planning and control code adapted from PythonRobotics retains its MIT notice. CARLA-derived Town01 maps retain their asset attribution and upstream terms.

Metadata

Release files for CarlaBEV 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CarlaBEV 0.9.0
File Size Uploaded Provenance Actions
carlabev-0.9.0.tar.gz 977.1 kB With provenance Details for carlabev-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for CarlaBEV 0.9.0
File Interpreter ABI Platform Actions
carlabev-0.9.0-py3-none-any.whl Python 3 none any Details for carlabev-0.9.0-py3-none-any.whl

Total release size: 1.9 MB

Release files / carlabev-0.9.0.tar.gz

Download URL carlabev-0.9.0.tar.gz
Size 977.1 kB
Tags Source
SHA-256 checksum
How to use checksums
67efd6edc71bb364367dac852a03cd9065ed61fd2b2731733c0974d483c5b4cf
BLAKE2b-256 checksum
How to use checksums
0ca520d4d701644c8d1418ebbe9ebb82a0a743d88b055d1dfe554a93552c17ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / carlabev-0.9.0-py3-none-any.whl

Download URL carlabev-0.9.0-py3-none-any.whl
Size 936.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7073c804ab1dbc77f724fc1b25af4c5578df45ad7de566f517ad8be851f6a34d
BLAKE2b-256 checksum
How to use checksums
b0e832369e75bc8bd2b3f8d8bb5a2172ce15dce27342307574fede9c22500ae2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for CarlaBEV 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for carlabev-0.9.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page