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.

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

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.