Skip to main content

Autonomous Vehicle Simulation Environment

Recreation of the simulation environment from the paper: "Safety and Risk Analysis of Autonomous Vehicles Using Computer Vision and Neural Networks" by Dixit et al. (2021)

Overview

This project recreates the three main case studies from the paper:

  1. Straight Lane Detection using Hough Line Transform
  2. Curved Lane Detection using OpenCV and HSV color space
  3. Behavioral Planning with Model-based Reinforcement Learning and Robust Control

Project Structure

├── av_simulation.py          # Main simulation with 3 environments (highway, merge, roundabout)
├── lane_detection.py          # Lane detection algorithms (straight & curved)
├── behavioral_planning.py     # MDP, MRL, and robust control implementation
├── requirements.txt          # Python dependencies
└── README.md                # This file

Features

1. Simulation Environments (av_simulation.py)

Based on Case Study 3, implements three driving scenarios:

  • Highway Environment: 4-lane highway with multiple vehicles
  • Lane Merging: Highway with service road merge point
  • Roundabout: 4-way roundabout navigation

Key Parameters from Paper:

  • Acceleration Range: (-5, 5.0) m/s²
  • Steering Range: ±45 degrees
  • Max Speed: 40 m/s
  • Default Speeds: [23, 25] m/s
  • Perception Distance: 180 m

2. Lane Detection (lane_detection.py)

Straight Lane Detection (Case Study 1):

  • Canny edge detection with 5×5 Gaussian filter
  • Region of Interest (ROI) segmentation
  • Hough Line Transform for lane marking detection
  • Line averaging and extrapolation

Curved Lane Detection (Case Study 2):

  • Camera distortion correction
  • Perspective transformation (bird's eye view)
  • HSV color space filtering for yellow/white lanes
  • Sobel operator for edge detection
  • 2nd-degree polynomial fitting: x = Ay² + By + C
  • Radius of curvature calculation

3. Behavioral Planning (behavioral_planning.py)

Model-Based Reinforcement Learning:

  • Neural network dynamics model: ẋ = f_θ(x, u) = A_θ(x, u)x + B_θ(x, u)u
  • Experience buffer with 2000 training epochs
  • Trajectory prediction with learned dynamics

Planning Algorithms:

  • Cross-Entropy Method (CEM) for trajectory optimization
  • Robust Control Framework with model uncertainty
  • Continuous Ambiguity Prediction for neighboring vehicles
  • Partially Observable MDP (POMDP) implementation

Installation

  1. Clone or download this repository
  2. Install dependencies:
pip install -r requirements.txt

Usage

Run Main Simulation

python av_simulation.py

Controls:

  • 1, 2, 3 - Switch between Highway, Merge, and Roundabout environments
  • SPACE - Pause/Resume
  • R - Reset current environment
  • Arrow Keys - Manual vehicle control (for testing)
  • ESC - Exit

The simulation includes:

  • Green ego vehicle with autonomous behavior planning
  • Blue traffic vehicles
  • Collision detection
  • Real-time speed and position display

Run Lane Detection Demo

python lane_detection.py

Controls:

  • s - Switch to Straight Lane Detection
  • c - Switch to Curved Lane Detection
  • q - Quit

The demo creates simulated road scenes and applies the detection algorithms.

Run Behavioral Planning Demo

python behavioral_planning.py

This runs a demonstration of:

  1. Model training with synthetic data
  2. Trajectory prediction
  3. Cross-entropy optimization
  4. Robust control with uncertainty
  5. Continuous ambiguity prediction

Implementation Details

Vehicle Dynamics

The vehicle model uses bicycle dynamics with state vector:

  • Position (x, y)
  • Velocity (vx, vy)
  • Heading angle
  • Current lane

Behavioral Planner

The planner considers:

  • Distance to front vehicle
  • Safe lane change opportunities
  • Speed maintenance within limits
  • Collision avoidance

Robust Control

Addresses model errors from Case Study 3:

  • Considers multiple possible future states
  • Worst-case scenario planning
  • Driving style estimation (aggressive/normal/conservative)

Key Findings Recreated

  1. Lane Detection: Successfully detects both straight and curved lanes using computer vision
  2. Behavioral Planning: MDP-based planning reduces collision risk
  3. Robust Control: Considering uncertainty prevents accidents shown in Figure 11 of the paper

Simulation Parameters

All parameters match Table 2 from the paper:

Parameter Value
Acceleration Range (-5, 5.0) m/s²
Steering Range (-0.785, 0.785) rad
Max Speed 40 m/s
Default Speeds [23, 25] m/s
Distance Wanted 10.0 m
Time Wanted 1.5 s
Perception Distance 180 m

Limitations

This is a simplified recreation for educational purposes:

  • Uses pygame instead of actual vehicle hardware
  • Synthetic data instead of real LIDAR/camera feeds
  • Simplified physics model
  • No actual V2X communication

Future Improvements

  • Add pedestrian and cyclist models
  • Implement V2X communication simulation
  • Add more complex road scenarios
  • Include weather conditions (fog, rain)
  • Implement full SCNN for better spatial feature detection

References

Dixit, A., Kumar Chidambaram, R., & Allam, Z. (2021). Safety and Risk Analysis of Autonomous Vehicles Using Computer Vision and Neural Networks. Vehicles, 3, 595-617.

License

This is an educational recreation of academic research. Please refer to the original paper for scientific details.

Metadata

Release files for av-simulation 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for av-simulation 1.0.1
File Size Uploaded Provenance Actions
av_simulation-1.0.1.tar.gz 46.8 kB Without provenance Details for av_simulation-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for av-simulation 1.0.1
File Interpreter ABI Platform Actions
av_simulation-1.0.1-py3-none-any.whl Python 3 none any Details for av_simulation-1.0.1-py3-none-any.whl

Total release size: 84.2 kB

Release files / av_simulation-1.0.1.tar.gz

Download URL av_simulation-1.0.1.tar.gz
Size 46.8 kB
Tags Source
SHA-256 checksum
How to use checksums
29018249ce2c7c2534e8eca43a1b194fe354079548781ef8ab985c5c6de89009
BLAKE2b-256 checksum
How to use checksums
cb75137762ea30ad3b62a6c783ccee4bdafb60b096a99af0864d05e5d21c476b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / av_simulation-1.0.1-py3-none-any.whl

Download URL av_simulation-1.0.1-py3-none-any.whl
Size 37.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4ef6357052dcc6e931929cca6ca62f63b0950d38be9a0d9e09727347b7f8d35
BLAKE2b-256 checksum
How to use checksums
c2fc1049a2f7b0cb1726efb0682eea03fdc29bcbfb8027b066a1d01bfa528ff3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for av-simulation 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page