sudo apt-get update
sudo apt-get install build-essential make cmake
# option 1: Install with sudo rights (cn-py37 is the name of conda environment).
cd ./commonroad_environment
bash ./scripts/install.sh -e cn-py37
# Option 2: Install without sudo rights
bash ./commonroad_environment/scripts/install.sh -e cn-py37 --no-root
[For Running with the Full HighD Data Only] Get the full dataset and Preprocess.
- Our repository uses some data examples from commonroad-rl tutorial. To build the full environments, you need to apply for the HighD dataset from here. The dataset is free for not non-commercial use.
- After you receive the data, do some preprocess according to Tutorial 01 - Data Preprocessing. We show a brief version as follow:
Once you have downloaded the data, extract all the .csv (e.g., 03_recordingMeta.csv
, 03_tracks.csv
, 03_tracksMeta.csv
) files to the folderCIRL-benchmarks-public/data/highD/raw/data/
, and then
cd ./commonroad_environment/install/
# install python packages
cd ./dataset-converters
pip install -r requirements.txt
# transfer raw data to .xml files
python -m src.main highD ../../../data/highD/raw/ ../../../data/highD/xmls/ --num_time_steps_scenario 1000
# compute the .pickle files
cd $YourProjectDir/CIRL-benchmarks-public/commonroad_environment/commonroad_rl
python -m commonroad_rl.tools.pickle_scenario.xml_to_pickle -i ../../data/highD/xmls -o ../../data/highD/pickles
# split the dataset
python -m commonroad_rl.utils_run.split_dataset -i ../../data/highD/pickles/problem -otrain ../../data/highD/pickles/problem_train -otest ../../data/highD/pickles/problem_test -tr_r 0.7
# scatter dataset for multiple processes
python -m commonroad_rl.tools.pickle_scenario.copy_files -i ../../data/highD/pickles/problem_train -o ../../data/highD/pickles/problem_train_split -f *.pickle -n 5
Throughout this section, we will use the HighD Velocity Constraint
environment as an example,
for using other environments (HighD Distance Constraint
please refer to their configs in this dir)
Note that the expert agent is to generate demonstration data (see the step 3 below).
# step in the dir containing the "main" files.
cd ./interface/
# run PPO-Lag knowing the constraint for speed constraint
python train_ppo.py ../config/highD_velocity_constraint/train_ppo_lag_highD_velocity_constraint.yaml -n 5 -s 123
Note that:
- you don't need to generate expert demonstrations since they are provided, but if you want to test other types of expert demonstrations, here is the code to start from:
- Since the generation relies on expert agent, we provide an example to you (named
train_ppo_lag_highD_no_slo_distance_penalty_bs--1_fs-5k_nee-10_lr-5e-4_dm-20-multi_env-Sep-25-2022-07:13-seed_123
).
# step in the dir containing the "main" files.
cd ./interface/
# run data generation
python generate_data_for_constraint_inference.py -n 5 -mn train_ppo_lag_highD_no_slo_distance_penalty_bs--1_fs-5k_nee-10_lr-5e-4_dm-20-multi_env-Sep-25-2022-07:13-seed_123 -tn PPO-Lag-highD-distance -ct no-too_closed-off_road
We use the HighD Velocity Constraint
environment as an example (also see the notice above).
Note that:
- This is to reproduce the results in the Section 5.1 of our paper.
- The following code uses the random seed '123'. For reproduction, a total of 3 random seeds ('123', '321', '666') are required.
# step in the dir containing the "main" files.
cd ./interface/
# run GACL
python train_gail.py ../config/highD_velocity_constraint/train_GAIL_highd_velocity_constraint.yaml -n 5 -s 123
# run BC2L
python train_cirl.py ../config/highD_velocity_constraint/train_Binary_highD_velocity_constraint.yaml -n 5 -s 123
# run MECL
python train_cirl.py ../config/highD_velocity_constraint/train_ICRL_highD_velocity_constraint.yaml -n 5 -s 123
# run VICRL
python train_cirl.py ../config/highD_velocity_constraint/train_VICRL_highD_velocity_constraint.yaml -n 5 -s 123
We use the HighD Velocity Constraint
environment as an example (also see the notice above).
Note that:
- This is to reproduce the results in the Section 5.2 of our paper.
- The following code uses the random seed '123'. For reproduction, a total of 3 random seeds ('123', '321', '666') are required.
# step in the dir containing the "main" files.
cd ./interface/
# run GACL
python train_gail.py ../config/highD_velocity_distance_constraint/train_GAIL_velocity_distance_constraint.yaml -n 5 -s 123
# run BC2L
python train_cirl.py ../config/highD_velocity_distance_constraint/train_Binary_highD_velocity_distance_constraint.yaml -n 5 -s 123
# run MECL
python train_cirl.py ../config/highD_velocity_distance_constraint/train_ICRL_highD_velocity_distance_constraint.yaml -n 5 -s 123
# run VICRL
python train_cirl.py ../config/highD_velocity_distance_constraint/train_VICRL_highD_velocity_distance_constraint.yaml -n 5 -s 123