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 DSRC 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; DSRC 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 playback_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 DSRC 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.7.2.tar.gz (175.2 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.7.2-py3-none-any.whl (60.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cavsandbox-0.7.2.tar.gz
  • Upload date:
  • Size: 175.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for cavsandbox-0.7.2.tar.gz
Algorithm Hash digest
SHA256 a7a263953ea58f271df5aee261843ce2c3d0f7c04b0a7c35b453bba125926423
MD5 f719a1783b29d70820c9a4eaea6c63fa
BLAKE2b-256 95e3d0f1c206dcc6fb1ffc6cdb9671fc27a17480d4ed4f5f0678c8ee25b09401

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cavsandbox-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 60.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for cavsandbox-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb973579315773f52b50ae8187d1b3922bc503f91baf431c4b65750be84da23b
MD5 84cfc7487b8568511b77c67ca1ba41e9
BLAKE2b-256 d54f9bc0eb73cea5d3203ede6fabc27edcdda237524bec69be435e8ff0258c1f

See more details on using hashes here.

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