Skip to main content

Autonomous Vehicle Simulation Environment

Project description

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.

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

av_simulation-1.0.1.tar.gz (46.8 kB view details)

Uploaded Source

Built Distribution

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

av_simulation-1.0.1-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file av_simulation-1.0.1.tar.gz.

File metadata

  • Download URL: av_simulation-1.0.1.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for av_simulation-1.0.1.tar.gz
Algorithm Hash digest
SHA256 29018249ce2c7c2534e8eca43a1b194fe354079548781ef8ab985c5c6de89009
MD5 aacc8f2945de5de8ca36058014aff13c
BLAKE2b-256 cb75137762ea30ad3b62a6c783ccee4bdafb60b096a99af0864d05e5d21c476b

See more details on using hashes here.

File details

Details for the file av_simulation-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: av_simulation-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 37.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for av_simulation-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d4ef6357052dcc6e931929cca6ca62f63b0950d38be9a0d9e09727347b7f8d35
MD5 815f8f94acf5099708900ecfade8979b
BLAKE2b-256 c2fc1049a2f7b0cb1726efb0682eea03fdc29bcbfb8027b066a1d01bfa528ff3

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