OpenCDA Installation


Requirements

To get started, the following requirements should be fulfilled.

  • System requirements. Any 64-bits OS should run OpenCDA. We highly recommends Ubuntu 16.04/18.04/20.04.

  • Adequate GPU. CARLA is a realistic simulation platform based on Unity, which requires at least a 3GB GPU for smooth scene rendering, though 8GB is recommended.

  • Disk Space. Estimate 30GB of space is recommended to install CARLA.

  • Python Python3,7 or higher version is required for full functions.


Local Installation

To get OpenCDA v0.1 running with complete functionality, you will need four things: CARLA, OpenCDA, and Pytorch(optional). Pytorch is required only when you want to activate the perception module, otherwise OpenCDA will retrieve all perception information from the simulation server directly.

1. CARLA Installation(0.9.11 required)

There are two different recommended ways to install the CARLA simulator and either way is fine for using OpenCDA.
** Note: If you want to use the customized highway map with full assets(.fbx, .xml and .xodr) in OpenCDA, you have to build from source. Visit CARLA’s tutorial ADD a new map for more information.

1.1 Package installation

OpenCDA is only tested at 0.9.11 and thus we highly recommend using this version. To install CARLA as a precompiled package, download and extract the release file. It contains a precompiled version of the simulator, the Python API module and some scripts to be used as examples.
** Note: The AdditionalMaps_0.9.11.tar.gz also need to be downloaded and extract to the CARLA repo to support scenario testings in Town06.

1.2 Build From Source

For advanced CARLA usage that involves extensive customizations, Build CARLA from Source is also supported by OpenCDA. Though source build in Windows OS is supported by CARLA, Ubuntu is the preferred OS as the OpenCDA was developoed in Ubuntu 18.04.

** Note: OpenCDA do not require CARLA source build. However, customized map with building/lane/traffic light/road surface materials assets in CARLA require source build. Visit CARLA’s tutorial [“ADD a new map”](`CARLA Tutorials (assets). <https://carla.readthedocs.io/en/latest/tuto_A_add_map_overview/) for more information.


2. OpenCDA Installation

First, download OpenCDA github to your local folder if you haven’t done it yet.

git clone https://github.com/ucla-mobility/OpenCDA.git
cd OpenCDA

Make sure you are in the root dir of OpenCDA, and next let’s install the dependencies. We highly recommend use conda environment to install.

conda env create -f environment.yml
conda activate opencda
python setup.py develop

If conda install failed, install through pip

pip install -r requirement.txt

After dependencies are installed, we need to install the CARLA PythonAPI package into the conda environment. You can do this by running this script:

export CARLA_HOME=/path/to/your/CARLA_ROOT
# remember to set CARLA_HOME first to point to your carla repo
. setup.sh

If everything works correctly, you will see a cache folder is created in your OpenCDA root dir, and inside the cache folder you will see an egg file and its unzipped folder. Then install this CARLA egg into your conda environment.

pip install -e cahce/carla-0.9.11-py3.7-linux-x86_64
python -c "import carla" # check whether carla is installed correctly.

**Note: If you are using Python other than 3.7 and CARLA rather than 0.9.11, then you have to change the setup.sh to your carla version’s egg file or manually installed carla to your conda environment.

3. Install Pytorch and Yolov5(Optional)

This section is only needed for the users who want to test perception algorithms. By default, OpenCDA does not require pytorch installed and it retrieves the object positions from the server directly. Once perception module is activated, then OpenCDA will use yolov5 with pytorch to run object detection.
To install pytorch based on your GPU and cuda version, go to the official pytorch website and install with conda command. Make sure you install pytorch >= 1.7.0. GPU Version highly recommended!

After pytorch installation, install the requirements for Yolov5.

pip install -qr https://raw.githubusercontent.com/ultralytics/yolov5/master/requirements.txt  # install dependencies