Road traffic accidents are often the result of the "reactive" nature of traditional safety systems (ADAS). To address this challenge, this project presents Road Safety and Traffic Diagnostics Assisted by AI, a real-time system designed to predict potential collisions before they occur.
The system utilizes ROS 2 as middleware to integrate traffic simulation (SUMO) with an LSTM Deep Learning model. It predicts the future trajectory of surrounding vehicles (5 seconds ahead) and assesses risk using Time-to-Collision (TTC) metrics. Experimental results demonstrated a prediction accuracy of RMSE ≈ 0.0511 and a system latency of <100ms, proving the feasibility of proactive safety on Edge Computing architectures.
Project Type: Senior Capstone Project (Phase 1: Proof of Concept). Grade: A+ (High Distinction).
The system classifies real-time risks into three categories based on the predicted trajectory:
Figure 1: System output showing Safe, Warning, and Critical alerts based on TTC calculation.
- Proactive Safety: Predicts hazards 3-5 seconds in advance instead of reacting to them.
- Deep Learning Core: Uses Long Short-Term Memory (LSTM) networks to analyze historical trajectory data (10 steps) and forecast future paths (5 steps).
- Real-Time Architecture: Built on ROS 2 Humble with a distributed node system ensuring sub-100ms response time.
- Risk Assessment Logic: Dynamic calculation of Euclidean Distance and TTC to classify risks into (Safe, Warning, Critical).
- Realistic Simulation: Validated on a digital twin of Taif City road network using OpenStreetMap (OSM) and SUMO/TraCI.
The system is designed with a modular architecture enabling seamless data flow between simulation and processing units.
Figure 2: High-level System Block Diagram showing the interaction between Sensing, Perception, Prediction, and Decision Layers.
The system is modularized into three main ROS 2 packages operating at a 10Hz synchronized frequency:
-
Data Publisher Node (
data_publisher):- Interfaces with SUMO via TraCI.
- Extracts raw vehicle states (X, Y, Speed) from the Taif City map simulation.
- Publishes to topic:
/raw/vehicle_state.
-
AI Prediction Node (
lstm_predictor):- Subscribes to raw data.
- Performs Normalization (MinMax Scaling).
- Runs the trained LSTM Model to predict the next 5 seconds of trajectory.
- Publishes to topic:
/prediction/paths.
-
Risk Assessment Node (
risk_assessor):- Calculates Euclidean Distance (
$d$ ) between the Ego vehicle and obstacles. - Applies Decision Logic:
- 🟢 Safe:
$d > 60m$ - 🟡 Warning:
$30m < d < 60m$ - 🔴 Critical:
$d < 30m$ (Triggers Alert).
- 🟢 Safe:
- Calculates Euclidean Distance (
The system was validated through rigorous simulation scenarios:
The LSTM model was trained to minimize Mean Squared Error (MSE), successfully capturing vehicle dynamics.
Figure 3: Training and Validation Loss Curve showing model convergence.
- Metric: Root Mean Square Error (RMSE) ≈ 0.0511.
The system visualizes the predicted path (Blue Line) against the actual ground truth (Red Prism) in real-time.
Figure 4: (Left) Rviz visualization of the predicted trajectory. (Right) RQT Graph confirming active ROS 2 nodes connection.
- Requirement: Real-time processing.
-
Result: End-to-end latency (Data Ingestion
$\to$ Alert) is < 100 milliseconds.
- Middleware: ROS 2 Humble Hawks.
- OS: Ubuntu 22.04 LTS (Linux).
- Language: Python 3.8+ (Nodes & Logic), C++.
- Simulation: SUMO (Simulation of Urban Mobility) & TraCI API.
- AI Frameworks: TensorFlow/Keras, Scikit-learn, Pandas, NumPy.
- Map Data: OpenStreetMap (OSM) - Taif City Network.
As outlined in the project roadmap and recommendations:
- High-Fidelity Simulation: Migration to CARLA Simulator to generate photorealistic sensor data (Virtual RGB-D Cameras & LiDAR) instead of utilizing direct coordinates from SUMO.
- Hardware-in-the-Loop (HIL): Deploy ROS 2 nodes on NVIDIA Jetson to test real-time processing latency using the data stream from CARLA.
- State Estimation: Implement Kalman Filters or similar algorithms to handle noise and uncertainty in the virtual sensor data.
This project was developed as a Senior Capstone Project by:
- Sadeem AlBoqami - Lead Developer & System Architect (ROS 2 & AI Implementation). LinkedIn
- Lujain AlMalki - [Data Preprocessing]
- Ahdab AlOttaibi - [LSTM Model - Training]
- Hutun AlAzwari - [LSTM Model - Testing]
- Shahad AlFahmi - [Risk Analysis]
- Almaha AlAyly - [Literature Review]
- Joud AlZahrani - [Literature Review]
- Joury AlSufyani - [System Analysis and Design]
Supervised by:
- Dr. Entesar Gemeay
Based on the research report: "Road Safety and Traffic Diagnostics Assisted by AI", Taif University, 2026.




