Skip to main content

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

cavsandbox-0.10.0.tar.gz (233.3 kB view details)

Uploaded Source

Built Distribution

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

cavsandbox-0.10.0-py3-none-any.whl (61.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cavsandbox-0.10.0.tar.gz
Algorithm Hash digest
SHA256 c182a6b3d4a63f661e9b68f8cf36750becb8228257d8fab1e0e933df620a7f0a
MD5 e7da43954e3dd02ffecd6df044902e57
BLAKE2b-256 26e5c4187c901b3f690412ae040cab88505d7294b342962e19ea7dea79243229

See more details on using hashes here.

Provenance

The following attestation bundles were made for cavsandbox-0.10.0.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.10.0-py3-none-any.whl.

File metadata

  • Download URL: cavsandbox-0.10.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

Hashes for cavsandbox-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ecf1f0f6e56a91fe45f1ea47527b2a713fef88e9c700129687acf3b2fafb180d
MD5 91ec2192e3694738fea4d3a877742d1b
BLAKE2b-256 b7d882d04fd0045b3d1c6d88b1327eb8c34a68e3201dce9d8a6656812dbc75c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cavsandbox-0.10.0-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