- Python100%
Autonomous Driving System
A modular autonomous-driving simulation project combining perception, decision logic, path planning, vehicle control, and a Streamlit dashboard. It is a simulation project, not a road-ready autonomous vehicle.
A modular autonomous-driving simulation project combining perception, decision logic, path planning, vehicle control, and a Streamlit dashboard. It is a simulation project, not a road-ready autonomous vehicle.
From README.md in the repository.
Industry-grade autonomous vehicle simulation system integrating deep-learning perception, rule-based + RL decision making, classical path planning, PID vehicle control, and a real-time Streamlit dashboard. Built as an AI/Autonomous Systems internship capstone portfolio project.
๐ Table of Contents
- Project Overview
- System Architecture
- Module Breakdown
- Installation
- Dataset Setup
- Running the System
- Training the RL Agent
- Evaluation
- Dashboard Usage
- Evaluation Metrics
- Results
- Project Structure
- Future Improvements
- References
๐ฏ Project Overview
This project implements a complete, modular autonomous driving pipeline capable of:
| Capability | Implementation |
|---|---|
| Lane detection | Hough Transform + temporal smoothing |
| Object detection | YOLOv11 (Ultralytics) + ByteTracker |
| Traffic sign recognition | YOLO + fine-grained CNN classifier |
| Depth estimation | Intel MiDaS (DPT_Large) |
| Driving decisions | Rule-based FSM + Behaviour Planner |
| Global path planning | A* search on occupancy grid |
| Local path planning | Pure Pursuit + potential fields |
| Vehicle control | PID + Stanley controller + AEB |
| End-to-end RL driving | PPO (Stable-Baselines3) |
| Simulation | CARLA 0.9.15+ (5 scenarios) |
| Monitoring | Streamlit real-time dashboard |
๐ System Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CARLA Simulator โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ RGB Camera โ โ Depth Cam โ โ LiDAR / GNSS / IMU โ โ
โ โโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโ โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ โผโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PERCEPTION LAYER โ
โ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ Lane Detectionโ โObject Detect โ โSign Detecโ โ Depth โ โ
โ โ (Hough+CV2) โ โ (YOLOv11) โ โ(YOLO+CNN)โ โ (MiDaS) โ โ
โ โโโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโ
โ โ โ โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PLANNING LAYER โ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Decision Engine โ โ Behavior Planner (FSM) โ โ
โ โ (Rule-based) โ โ IDLEโLANE_FOLLOWINGโINTERSECT.. โ โ
โ โโโโโโโโโโฌโโโโโโโโโโ โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Path Planner: A* Global + Pure Pursuit Local โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CONTROL LAYER โ
โ โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ Steering (PID+ โ โ Throttle (PID) โ โ AEB โ โ
โ โ Stanley) โ โ Speed control โ โ Emergency โ โ
โ โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โ RL Agent (PPO) โ โ Optional end-to-end
โ Stable-Baselines3 โ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โ Streamlit Dashboard โ
โ (Live monitoring) โ
โโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฉ Module Breakdown
Perception (perception/)
| File | Description |
|---|---|
lane_detection.py |
Canny + Hough lane detection, temporal smoothing, lane-centre computation |
object_detection.py |
YOLOv11 wrapper, distance estimation, threat classification, ByteTrack |
traffic_sign_detection.py |
Two-stage YOLO+CNN, HSV traffic-light colour parsing |
depth_estimation.py |
MiDaS monocular depth, per-object distance enrichment |
Planning (planning/)
| File | Description |
|---|---|
decision_engine.py |
Prioritised rule-stack: emergency brake โ red light โ pedestrian โ follow โ cruise |
behavior_planner.py |
Hierarchical FSM with 9 states + lane-change logic |
path_planner.py |
A* global planner on occupancy grid + Pure Pursuit local planner |
Control (control/)
| File | Description |
|---|---|
pid_controller.py |
Generic PID with anti-windup, derivative filter, gain scheduling |
steering_control.py |
PID + Stanley controller fusion for lateral control |
throttle_control.py |
PID longitudinal control + Automatic Emergency Braking (AEB) |
Simulation (simulation/)
| File | Description |
|---|---|
carla_env.py |
Gymnasium-compatible CARLA environment, 5 scenarios, reward shaping |
sensors.py |
Thread-safe sensor manager: RGB, depth, semantic, LiDAR, GNSS/IMU |
RL Agent (rl_agent/)
| File | Description |
|---|---|
train.py |
PPO trainer with custom CNN feature extractor, EvalCallback, W&B logging |
evaluate.py |
Structured evaluation across all scenarios, JSON/CSV report generation |
โ๏ธ Installation
Prerequisites
- Ubuntu 20.04+ or Windows 10/11
- Python 3.11+
- NVIDIA GPU with CUDA 11.8+ (recommended; CPU fallback available)
- CARLA 0.9.15 (download)
Step 1 โ Clone & Create Environment
git clone https://github.com/yourusername/autonomous-driving-system.git
cd autonomous-driving-system
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
Step 2 โ Install Python Dependencies
pip install --upgrade pip
pip install -r requirements.txt
Step 3 โ Install CARLA Python Client
# For CARLA 0.9.15
pip install carla==0.9.15
# OR install from the CARLA PythonAPI egg (if server is local)
cd /opt/carla/PythonAPI/carla/dist
pip install carla-0.9.15-cp311-cp311-linux_x86_64.whl
Step 4 โ Download YOLO Weights
# YOLOv8n (auto-downloads on first run)
python -c "from ultralytics import YOLO; YOLO('yolov8n.pt')"
# Or for YOLOv11:
python -c "from ultralytics import YOLO; YOLO('yolo11n.pt')"
Step 5 โ Verify Installation
python main.py --mode benchmark
๐ฆ Dataset Setup
CARLA โ No dataset download needed
The CARLA simulator generates synthetic sensor data in real-time. Start the server and the system auto-collects training data.
Optional: Pre-trained Sign Classifier
For enhanced traffic-sign classification, train the CNN on:
| Dataset | Classes | Link |
|---|---|---|
| German Traffic Sign (GTSRB) | 43 | Kaggle |
| LISA Traffic Sign Dataset | 47 | UCSD |
# Prepare dataset
mkdir -p datasets/traffic_signs
# Download and extract to datasets/traffic_signs/
# Expected structure:
# datasets/traffic_signs/
# train/ (class_0/, class_1/, ...)
# val/
# test/
Train the sign classifier:
python scripts/train_sign_classifier.py \
--data datasets/traffic_signs \
--epochs 50 \
--output models/sign_classifier.pt
๐ Running the System
1. Start CARLA Server (separate terminal)
# Linux
cd /opt/carla
./CarlaUE4.sh -carla-server -fps=20 -ResX=1280 -ResY=720
# Windows
CarlaUE4.exe -carla-server -fps=20
2. Rule-Based Agent
# Default straight road scenario
python main.py --mode rule --scenario STRAIGHT_ROAD
# Urban traffic scenario
python main.py --mode rule --scenario DENSE_URBAN --steps 3000
# Night driving
python main.py --mode rule --scenario NIGHT_DRIVING --device cuda
3. RL Agent Inference
python main.py --mode rl \
--model models/ppo_autonomous_driver_final \
--scenario INTERSECTION
4. All 5 Scenarios (Sequential)
for SCENARIO in STRAIGHT_ROAD INTERSECTION PEDESTRIAN_CROSS DENSE_URBAN NIGHT_DRIVING; do
python main.py --mode rule --scenario $SCENARIO --steps 1000
done
๐ง Training the RL Agent
# Quick training (testing)
python main.py --mode train --timesteps 50000 --scenario STRAIGHT_ROAD
# Full training
python main.py --mode train --timesteps 500000 --scenario DENSE_URBAN
# OR via the training script directly (more options)
python rl_agent/train.py \
--timesteps 500000 \
--scenario INTERSECTION
# Resume from checkpoint
python rl_agent/train.py \
--resume models/ppo_autonomous_driver_100000_steps.zip \
--timesteps 400000
# Monitor with TensorBoard
tensorboard --logdir results/rl_logs
Reward Function
| Event | Reward |
|---|---|
| Lane keeping (offset < 0.5 m) | +1.0 |
| Progress toward destination | +2.0 ร delta |
| Speed compliance | +0.5 |
| Smooth steering | +0.2 |
| Collision | โ5.0 + episode end |
| Lane departure | โ3.0 |
| Accident (major) | โ10.0 |
๐ Evaluation
# Evaluate all 5 scenarios (5 episodes each)
python main.py --mode eval \
--model models/ppo_autonomous_driver_final \
--episodes 5
# Evaluate single scenario
python rl_agent/evaluate.py \
--model models/ppo_autonomous_driver_final \
--scenario INTERSECTION \
--episodes 10
# Perception latency benchmark
python main.py --mode benchmark
# View results
cat results/evaluation_report.json
Evaluation output: results/evaluation_report.json, results/evaluation_metrics.csv,results/episode_details.csv
๐บ Dashboard Usage
streamlit run dashboard/app.py
# Opens at http://localhost:8501
Dashboard Features
| Panel | Content |
|---|---|
| Live Feed | Front camera with lane + detection overlays |
| Speed Gauge | Real-time speedometer (0โ120 km/h) |
| Steering Gauge | Steering angle indicator (ยฑ1.0) |
| Warning Panel | AEB, collision, lane departure, overspeed alerts |
| Drive State | Current FSM state (CRUISING / EMERGENCY_BRAKE / ...) |
| Metrics Tab | Rolling speed, steer, reward, FPS time-series charts |
| Detections Tab | Live detection table + class distribution chart |
| Evaluation Tab | Loaded evaluation report with scenario bar charts |
| System Info Tab | Architecture overview, quick-start guide |
๐ Evaluation Metrics
| Metric | Formula | Target |
|---|---|---|
| Collision Rate | Collisions / episode | < 0.1 |
| Lane Keeping Accuracy | Steps within 0.5m / total steps | > 85% |
| Success Rate | Episodes without collision & > 80% route | > 70% |
| Route Completion | Steps completed / max steps | > 80% |
| Average Speed | Mean speed (km/h) during episode | โ cruise target |
| Inference Latency | Per-module forward pass (ms) | < 50ms/frame |
| Detection mAP | YOLO mAP@0.5 on test set | > 0.75 |
๐ Project Structure
autonomous_driving/
โ
โโโ perception/ # Sensing & interpretation
โ โโโ lane_detection.py # Hough-transform lane detector
โ โโโ object_detection.py # YOLOv11 multi-class detector
โ โโโ traffic_sign_detection.py # YOLO + CNN sign classifier
โ โโโ depth_estimation.py # MiDaS monocular depth
โ
โโโ planning/ # Intelligence layer
โ โโโ decision_engine.py # Rule-based priority engine
โ โโโ behavior_planner.py # FSM behavior planner
โ โโโ path_planner.py # A* + Pure Pursuit planner
โ
โโโ control/ # Actuation
โ โโโ pid_controller.py # Generic PID controller
โ โโโ steering_control.py # Steering + Throttle + AEB
โ
โโโ simulation/ # CARLA interface
โ โโโ carla_env.py # Gymnasium environment
โ โโโ sensors.py # Sensor manager
โ
โโโ rl_agent/ # Reinforcement learning
โ โโโ train.py # PPO training pipeline
โ โโโ evaluate.py # Evaluation & benchmarking
โ
โโโ dashboard/ # Monitoring
โ โโโ app.py # Streamlit dashboard
โ
โโโ configs/
โ โโโ config.yaml # Central configuration
โ
โโโ models/ # Trained weights
โโโ datasets/ # Training data
โโโ results/ # Logs, reports, checkpoints
โ
โโโ main.py # System orchestrator + CLI
โโโ requirements.txt
โโโ README.md
๐ฎ Future Improvements
- Semantic Segmentation โ Replace Hough lanes with DeepLabV3+/SegFormer drivable-area mask
- Transformer Perception โ DETR / BEVFormer for multi-view object detection
- Multi-Camera Fusion โ 360ยฐ surround-view with BEV projection
- LiDAR Integration โ PointPillar / VoxelNet for LiDAR object detection
- HD Map Integration โ OpenDRIVE map parsing for precise path planning
- V2X Communication โ Vehicle-to-infrastructure signal simulation
- Driver Monitoring โ Drowsiness / distraction detection
- Imitation Learning โ Pre-training from expert CARLA demonstrations
- Uncertainty Estimation โ Bayesian detection confidence for safety
- Real-world Deployment โ ROS2 + Autoware.Universe integration
๐ References
- Dosovitskiy et al. (2017) โ CARLA: An Open Urban Driving Simulator
- Redmon et al. โ YOLO: Real-Time Object Detection
- Ranftl et al. (2021) โ Vision Transformers for Dense Prediction (MiDaS)
- Schulman et al. (2017) โ Proximal Policy Optimization
- Coulter (1992) โ Pure Pursuit Path Tracking
- Hart, Nilsson, Raphael (1968) โ A* Search Algorithm
๐จโ๐ป Author
Built as an AI/Autonomous Systems Internship Capstone Project.
Demonstrates mastery of: deep learning ยท computer vision ยท robotics ยท reinforcement learning ยท simulation ยท software engineering.
Tech Stack: Python ยท PyTorch ยท OpenCV ยท Ultralytics YOLOv11 ยท MiDaS ยท Stable-Baselines3 ยท CARLA ยท Streamlit ยท NumPy ยท Pandas
โญ Star this repo if it helped you! ยท ๐ด Fork it for your own project
Resources
GitHub data synced 25 Oct 2026