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:
- Straight Lane Detection using Hough Line Transform
- Curved Lane Detection using OpenCV and HSV color space
- 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
- Clone or download this repository
- 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 environmentsSPACE- Pause/ResumeR- Reset current environmentArrow 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 Detectionc- Switch to Curved Lane Detectionq- 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:
- Model training with synthetic data
- Trajectory prediction
- Cross-entropy optimization
- Robust control with uncertainty
- 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
- Lane Detection: Successfully detects both straight and curved lanes using computer vision
- Behavioral Planning: MDP-based planning reduces collision risk
- 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
Release history Release notifications | RSS feed
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 av_simulation-1.0.0.tar.gz.
File metadata
- Download URL: av_simulation-1.0.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b187eb10ba21c9831fa5648f02d2c9017625d5a0bbab5108ee9198c69bc1eaf9
|
|
| MD5 |
cf07eae6fc8459c853bdbb79a808a1f2
|
|
| BLAKE2b-256 |
019c4468ed150ca0ceed34f3a6bae7ca45fa115a4ddfc6bcfedd3a9349b08f69
|
File details
Details for the file av_simulation-1.0.0-py3-none-any.whl.
File metadata
- Download URL: av_simulation-1.0.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1729acc462925ba1b5e3ce434f637a6c940a5f025610bac44cb1da9dcc7afa65
|
|
| MD5 |
1e7372943ebf42d91d4a4643424252c8
|
|
| BLAKE2b-256 |
7f4eb24cebfa5363d29ebc8bc701f71046d7cfc3cd37bdab393821de2c3a94cd
|