If you use this GitHub repository, the framework, or the dataset in your work, please cite the open-source article provided in the Citation section.
This framework introduces: (i) a novel public dataset of human-performed simulated lane change maneuvers; (ii) a dedicated CARLA highway map designed for extended driving sessions; and (iii) tools to facilitate data collection and model evaluation. Below is a high-level overview of the workflow:
The map can be downloaded from this link. Unzip it into the maps folder of the repository.
The main.py script facilitates data collection for training and evaluating the lane change intention recognition model.
- Sensor Integration: Interfaces with vehicle sensors (e.g., steering angle, speed, turn signals) to gather real-time driving data.
- Environment Data Collection: Collects data from the CARLA simulator, including vehicle dynamics and environmental conditions.
- Data Logging: Saves the collected data into structured log files for later analysis.
- Configuration: Customize parameters like sampling rate and storage paths in the script.
Refer to main.py for implementation details.
- Map Configuration: Set the map path in
config.json. - Create a Virtual Environment:
- Using
venv:python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Using
conda:conda create -n LC-data-collection python=3.8 conda activate LC-data-collection
- Using
- Install Dependencies:
pip install -r requirements.txt
The main.py script serves as the entry point for interacting with the CARLA simulator.
- Configuration Loading: The script loads a
config.jsonfile to customize gameplay settings, such as baseline or treatment modes. - Command-Line Arguments:
--host,--port: Specify CARLA server IP and port.--autopilot: Enable autopilot mode.--record,--savevideo: Record frames and save simulation videos.--baseline: Use baseline mode.--treatment: Use treatment mode.
- Synchronous Mode: Ensures precise simulation timing.
- Steering Wheel Simulation: Optionally activate a steering wheel controller.
Run the script with desired options:
python main.py [options]Examples:
python main.py --port 2000 --wheel --baseline
python main.py --port 2000 --wheel --treatmentCollected data is saved to a log file for replication or conversion into training and evaluation datasets.
This repository includes the pipeline for preparing data and training models to predict lane changes.
- Log Conversion: Convert
.txtlogs to.h5(CDF format) usinggenerate_CDF_Carla_log_to_H5.py. - Feature Extraction: Extract 30 features and label timestamps using
h5_to_CSV_and_labeling.py:- Labels:
0–4: Lane change direction.4.1: Free ride (no lane change)."-": Ignored timestamps (up to 1.5 seconds after a lane change).
- Labels:
- Windowing: Segment data into overlapping 5-second windows at 10 Hz.
- Normalization: Scale data for consistency.
- Model Training: Train models using Bayesian optimization.
../maps: Place theLC_Simulatorfolder here.⚠️ Ensure it matches the map used during data collection.h5/: Stores generated.h5files.dataset/: Contains processed.csvfiles with features and labels.machine_learning/: Scripts and notebooks for model training and evaluation.
Inside the folder data_preparation
- Create and activate a conda environment:
conda create -n lc_data_preparation python=3.10.14 conda activate lc_data_preparation
- Install dependencies:
pip install -r requirements.txt
dataset_preparation/dataset and you can skip directly to Step 3.
Place the LC_Simulator folder into the ../maps/ directory. .txt logs.
- Open
generate_CDF_Carla_log_to_H5.pyand specify the log files. - Run the script. If a
RuntimeError: time-out...occurs, re-run it. - Output
.h5files are saved in theh5/folder.
- Open
h5_to_CSV_and_labeling.pyand specify the.h5files. - Extract features and label timestamps:
0–4: Lane change direction.4.1: Free ride."-": Ignored timestamps.
- Output
.csvfiles are saved in thedataset/folder.
-
From the
dataset_preparation/datasetfolder move manually the following user todataset_preparation/machine_learning/validation,dataset_preparation/machine_learning/testing,dataset_preparation/machine_learning/training -
If you downloaded the dataset from Zenodo, please split the users into separate folders to ensure user-independent training and comparable results:
- Validation: Users 5, 8, 10, 12, 16, 19, 27.
- Testing: Users 2, 7, 13, 18, 25, 31, 36.
- Training: Remaining users.
Run CSV_to_windows_by_users_5s.ipynb in the machine_learning/ folder. Output is saved in the data/ directory.
- Navigate to
machine_learning/regression_lc_fr_5s/. - Run
regression_lc_fr.ipynb:- Normalize the dataset.
- Train models using Bayesian optimization.
- Output is saved in the
data_prepared/folder.
Enjoy using the Lane Change Intention Recognition Framework!
If you used either the framework or the dataset in your work, please cite the related open-source paper as:
@ARTICLE{11271346,
author={Forneris, Luca and Berta, Riccardo and Fresta, Matteo and Lazzaroni, Luca and Rojhan, Hadise and Oh, Changjae and Pighetti, Alessandro and Ballout, Hadi and Tango, Fabio and Bellotti, Francesco},
journal={IEEE Signal Processing Letters},
title={A Deployment-oriented Simulation Framework for Deep Learning-based Lane Change Prediction},
year={2025},
volume={},
number={},
pages={1-5},
keywords={Data models;Vehicle dynamics;Transformers;Training;Time series analysis;Synthetic data;Long short term memory;Roads;Pipelines;Data collection;Automated driving functions;dataset;deep learning;driver assistance systems;simulation;time-to-lane change prediction;Transformer;XGBoost},
doi={10.1109/LSP.2025.3638676}}