This repository contains traffic scenario definition and an execution engine for CARLA. It also allows the execution of a simulation of the CARLA Challenge. You can use this system to prepare your agent for the CARLA Challenge.
Scenarios can be defined through a Python interface, and with the newest version the scenario_runner also the upcoming OpenScenario standard is supported.
Use git clone
or download the project from this page. Note that the master
branch contains the latest fixes and features, and may be required to use the latest features from CARLA.
It is important to also consider the release version that has to match the CARLA version.
- Version 0.9.6: Compatible with CARLA 0.9.6
- Version 0.9.5 and Version 0.9.5.1: Compatible with CARLA 0.9.5
- Version 0.9.2: Compatible with CARLA 0.9.2
To use a particular version you can either download the corresponding tarball or simply checkout the version tag associated to the release (e.g. git checkout v0.9.5)
Currently no build is required, as all code is in Python.
Please take a look at our Getting started documentation.
You can evaluate your own agents using a reproduction of the CARLA Challenge by following this tutorial
Please take a look at our Contribution guidelines.
If you run into problems, check our FAQ.
ScenarioRunner specific code is distributed under MIT License.
- Install UnrealEngine4.22 and Latest CARLA following [How to build CARLA on Linux].
Note:
- clone
master
branch instead ofstable
branch to aviod "No rule to build target 'launch'" error. (Two branches have totally different Makefile) - They just updated the Releases to 0.9.6, but I am using 0.9.5.
- Clone this repo and follow Getting started documentation.
- Python3.5
- After [building] and Getting started and some configurations, my
~/.bashrc
looks like the followings:
# >>> for CARLA >>>
# start UE as CARLA's server
export UE4_ROOT=~/UnrealEngine_4.22
export CARLA_ROOT=/home/ruihan/UnrealEngine_4.22/carla/
export PYTHONPATH=${CARLA_ROOT}/PythonAPI/carla:$PYTHONPATH
export CARLA_SERVER_DIR=/home/ruihan/UnrealEngine_4.22/carla/Unreal/CarlaUE4/Saved/StagedBuilds/LinuxNoEditor
# export CARLA_SERVER=/home/ruihan/UnrealEngine_4.22/carla/Unreal/CarlaUE4/Saved/StagedBuilds/LinuxNoEditor/CarlaUE4.sh
# for conditional imitation learning
export PYTHONPATH=/home/ruihan/coiltraine:$PYTHONPATH
# for CARLA AD Challenge, scenario_runner
export ROOT_SCENARIO_RUNNER=/home/ruihan/scenario_runner
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/carla/dist/carla-0.9.5-py3.5-linux-x86_64.egg:${CARLA_ROOT}/PythonAPI/carla/agents:${CARLA_ROOT}/PythonAPI/carla
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/carla/:${ROOT_SCENARIO_RUNNER}:${CARLA_ROOT}/PythonAPI/carla/dist/carla-0.9.5-py2.7-linux-x86_64.egg:${CARLA_ROOT}/PythonAPI/carla/agents
(coiltraine
environment is not necessary if all other required packages are installed)
- Run the commands
- To collect data from
manual_control.py
, pressP
on keyboard to enableautopilot
modify ~L265 (about line 265)def write_in_csv(location, waypoint_tf, lane_width, control, ds='localization_relative_coords_ds.csv')
to change dataset filename.
Addrecord_dataset
andwrite_in_csv
methods to originalmanual_control.py
ruihan@depend-XPS-8930:cd $CARLA_SERVER_DIR
ruihan@depend-XPS-8930:~/UnrealEngine_4.22/carla/Unreal/CarlaUE4/Saved/StagedBuilds/LinuxNoEditor$ ./CarlaUE4.sh
(coiltraine) ruihan@depend-XPS-8930:~/scenario_runner$ python scenario_runner.py --scenario BackgroundActivity_1 --reloadWorld
(coiltraine) ruihan@depend-XPS-8930:~/scenario_runner$ python manual_control_record.py
- To train the NN_controller
ruihan@depend-XPS-8930:~/scenario_runner$ python NN_controller.py
modify ~L58ds_file = 'localization_relative_coords_ds.csv'
(input dataset) and ~L158torch.save(model, 'models/NN_model_relative_epo50.pth')
(output model) - To test the NN_controller, press
N
on keyboard to enable NN_controller
Addget_nn_controller
method tomanual_control_record.py
ruihan@depend-XPS-8930:~/UnrealEngine_4.22/carla/Unreal/CarlaUE4/Saved/StagedBuilds/LinuxNoEditor$ ./CarlaUE4.sh
(coiltraine) ruihan@depend-XPS-8930:~/scenario_runner$ python scenario_runner.py --scenario BackgroundActivity_1 --reloadWorld
(coiltraine) ruihan@depend-XPS-8930:~/scenario_runner$ python manual_control_test_NN.py
Modify ~L118 def __init__(self, carla_world, hud, nn_model_path='models/NN_model_epo50.pth'):
to change the path of the model to be tested.
- To see the performance of CoIL
ruihan@depend-XPS-8930:~/UnrealEngine_4.22/carla/Unreal/CarlaUE4/Saved/StagedBuilds/LinuxNoEditor$ ./CarlaUE4.sh -benchmark -fps=20 -quality-level=Epic
(coiltraine) ruihan@depend-XPS-8930:~/scenario_runner$ bash srunner/challenge/run_evaluator_co.sh
ruihan@depend-XPS-8930:~/UnrealEngine_4.22/carla/Unreal/CarlaUE4/Saved/StagedBuilds/LinuxNoEditor$ ./CarlaUE4.sh -benchmark -fps=20 -quality-level=Epic
(coiltraine) ruihan@depend-XPS-8930:~/scenario_runner$ bash srunner/challenge/run_evaluator_NN.sh
- Collect data in senario_runner setting
ruihan@depend-XPS-8930:~/UnrealEngine_4.22/carla/Unreal/CarlaUE4/Saved/StagedBuilds/LinuxNoEditor$ ./CarlaUE4.sh
(coiltraine) ruihan@depend-XPS-8930:~/scenario_runner$ python scenario_runner.py --scenario BackgroundActivity_1 --reloadWorld
(coiltraine) ruihan@depend-XPS-8930:~/scenario_runner$ python manual_control_record_e2c.py
collected data (image .png and control .npy) are saved in /data
folder but are not uploaded to remote repo
-
Parse data and train the model
(coiltraine) ruihan@depend-XPS-8930:~/scenario_runner$ python e2c_controller.py
ORe2c_controller_cat.py
(which concatenate measurement to latent vector), which load the/data/processed.pkl
file as data source. -
Note: modify
save_dir
inmanual_control_record_e2c.py
=>_parse_image_and_save
,ds_dir
andmodel_path
ine2c_controller_cat.py
, corespondingly.