Python simulation of longitudinal car-following with ACC, CACC, and human driver models
Project description
CAVSandbox
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 |
| User Guide (coming soon) | Full reference for all parameters and output formats |
| Worked Examples (coming soon) | Pre-built research scenarios with interpretation |
| Plugin Author Guide (coming soon) | 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cavsandbox-0.9.0.tar.gz.
File metadata
- Download URL: cavsandbox-0.9.0.tar.gz
- Upload date:
- Size: 218.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e1e406ba804787ee69a85008c82dbea1c286a475931605aa2cc0be85631b144
|
|
| MD5 |
50f10b2ca790c352f91d2eb19440ead9
|
|
| BLAKE2b-256 |
628736794d344d796901c32802db6fa1f2c2d15ad6e682ae052994388e597e57
|
Provenance
The following attestation bundles were made for cavsandbox-0.9.0.tar.gz:
Publisher:
publish.yml on ViennaMike/CAVSandbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cavsandbox-0.9.0.tar.gz -
Subject digest:
0e1e406ba804787ee69a85008c82dbea1c286a475931605aa2cc0be85631b144 - Sigstore transparency entry: 1417092748
- Sigstore integration time:
-
Permalink:
ViennaMike/CAVSandbox@c88eebbd1bc6e14704bd1ca8b0f2e3d31e335949 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/ViennaMike
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c88eebbd1bc6e14704bd1ca8b0f2e3d31e335949 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cavsandbox-0.9.0-py3-none-any.whl.
File metadata
- Download URL: cavsandbox-0.9.0-py3-none-any.whl
- Upload date:
- Size: 61.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a1b10033e57c1b68295d9a5d7f287c86c83ef3ca9eb8beedbaa29ae59f11efa
|
|
| MD5 |
02e7a0dcc33beb7f831a5672b4a02d76
|
|
| BLAKE2b-256 |
c328bc92c2d859afac56cd1a17d76603fbf1cf5febf8b73401b322c246e69a3b
|
Provenance
The following attestation bundles were made for cavsandbox-0.9.0-py3-none-any.whl:
Publisher:
publish.yml on ViennaMike/CAVSandbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cavsandbox-0.9.0-py3-none-any.whl -
Subject digest:
4a1b10033e57c1b68295d9a5d7f287c86c83ef3ca9eb8beedbaa29ae59f11efa - Sigstore transparency entry: 1417092754
- Sigstore integration time:
-
Permalink:
ViennaMike/CAVSandbox@c88eebbd1bc6e14704bd1ca8b0f2e3d31e335949 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/ViennaMike
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c88eebbd1bc6e14704bd1ca8b0f2e3d31e335949 -
Trigger Event:
push
-
Statement type: