Skip to main content

Python simulation of longitudinal car-following with ACC, CACC, and human driver models

Project description

CAVSandbox logo with cars, sine waves, and open simulation with python tagline

A Python simulation of longitudinal car-following for Adaptive Cruise Control (ACC), Cooperative ACC (CACC), and human driver models. Designed as a teaching and research tool for students and researchers studying car-following behavior, advanced cruise control, and connected and automated vehicles.

CAVSandbox models three driver types: human, ACC, and CACC. There is a built-in driver model for each of these types, but a plugin system allows the user to substitute their own driver models. The simulation includes realistic radar noise, IMU noise, and V2V communications. All scenario configuration is done in Excel; no code changes are needed to run or modify scenarios (except for new plugins).

Features

  • Built-in driving models — IDM human driver, IDM ACC, CACC with V2V feedforward, prescribed lead vehicle profile
  • Realistic sensor pipeline — radar noise and delay with Kalman or low-pass filter; IMU bias drift; V2V BSM comms with packet drop and multi-rate fusion Kalman filter. Also the ability to turn these off for simple pass-throughs, if desired.
  • Vehicle response model — first-order actuator lag with passive drag; kinematic mode for quick prototyping
  • Plugin system — drop a Python file in plugins/ to add new driving models or filters; no core edits required
  • Live Pygame renderer — top-down road view color-coded by model type, scrolling road markers, real-time speed chart, pause/resume
  • CSV playback — replay any saved run through the live renderer with seek, step, and variable speed controls
  • Post-run output — CSV state log, five-panel matplotlib plots, YAML metadata, and input Excel copy, all written to results/
  • Excel input — configure vehicles, scenario, and lead profile in a spreadsheet; no code changes needed

Quick Start

Prerequisites: Python 3.11+ and uv.

pip install uv
git clone https://github.com/ViennaMike/cavsandbox.git
cd cavsandbox
uv pip install -e .
python -m cacc_sim.main examples/quickstart.xlsx

A Pygame window opens showing a four-vehicle CACC platoon following a step-change deceleration. Results are written to results/quickstart_<timestamp>/ when the run completes.

For a complete walkthrough including how to modify scenarios and interpret results, see the Quick-Start Guide.

Common Commands

# Run a simulation (live window)
python -m cacc_sim.main examples/quickstart.xlsx

# Run headless (set simulation_speed=0 in the Excel simulation sheet)
python -m cacc_sim.main my_scenario.xlsx

# Replay a saved run
python -m cacc_sim.main results/my_scenario_<timestamp>/data.csv

# Regenerate plots from an existing CSV
python -m cacc_sim.plot results/my_scenario_<timestamp>/data.csv --show

# Run tests
pytest

Documentation

Document Audience
Quick-Start Guide All users — install, run, and modify your first scenario
Input Template Blank template for the scenario input Excel workbook.
User Guide Full reference for all parameters and output formats
Worked Examples Pre-built research scenarios with interpretation
Plugin Author Guide Write new driving models and filters
CACC Design Notes Maintainers and contributors — architecture and design rationale

Project Status

All seventeen steps of the planned development sequence are complete. The simulation supports:

  • Four built-in driving models plus the Wiedemann99 plugin
  • Passthrough and realistic sensor pipelines (Kalman filter and low-pass filter)
  • Passthrough and V2V comms with multi-rate fusion Kalman filter
  • Full five-panel post-run plotting and CSV/YAML output
  • Real-time Pygame visualization and CSV playback

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cavsandbox-0.11.2.tar.gz (23.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cavsandbox-0.11.2-py3-none-any.whl (61.3 kB view details)

Uploaded Python 3

File details

Details for the file cavsandbox-0.11.2.tar.gz.

File metadata

  • Download URL: cavsandbox-0.11.2.tar.gz
  • Upload date:
  • Size: 23.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cavsandbox-0.11.2.tar.gz
Algorithm Hash digest
SHA256 e1870a8c0543dc2daad08fd9cc78ef8e14b168d25d49cd00f81399e74dbe92a2
MD5 90d7f3e0e5e6dedb26a7aa2704e46cb1
BLAKE2b-256 011868fbacb0dd472dc9056cdb5bf1bfb5c353a1f9105fb6094ccdbf17c055bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for cavsandbox-0.11.2.tar.gz:

Publisher: publish.yml on ViennaMike/CAVSandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cavsandbox-0.11.2-py3-none-any.whl.

File metadata

  • Download URL: cavsandbox-0.11.2-py3-none-any.whl
  • Upload date:
  • Size: 61.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cavsandbox-0.11.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f63d0e09a3d6b36785d57ea95ee0bf6e9ae0ccf7d1b4c3012a547809b96cb1d8
MD5 f484163669d6208e4c8501d816529935
BLAKE2b-256 53e523a644aca29401642278256af49460f94dcc3473b3b3a3bd737811dd68b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cavsandbox-0.11.2-py3-none-any.whl:

Publisher: publish.yml on ViennaMike/CAVSandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page