Autonomous Driving Simulator CARLA using Docker

CARLA, an open-source simulator for autonomous driving research, provides Docker images, and you can easily set up CARLA by using one of these Docker images.
In this article, we will show you how to set up CARLA using Docker.

CARLA

CARLA (Car Learning to Act) is an open-source simulator based on Unreal Engine 4 for autonomous driving research.
For details, please visit the following site.

CARLA Setup using Docker

By using Docker image, you can easily set up CARLA.

Prerequisites

  • Ubuntu 16.04 or later
  • Docker
  • NVIDIA Docker2
  • NVIDIA Driver >= 390

Setup CARLA Server

Use the following command to download the Docker image (Docker for CARLA) to be operated as a CARLA server.

$ docker pull carlasim/carla:0.8.4

Because the Docker image is large, downloading takes time.

Setup Python Client

Setup the Python client with the following command.

$ cd ~
$ wget https://github.com/carla-simulator/carla/archive/0.8.4.tar.gz
$ tar xf 0.8.4.tar.gz
$ rm 0.8.4.tar.gz
$ cd ~/carla-0.8.4
$ pip3 install -r PythonClient/requirements.txt

According to Docs, Python 3.5 is recommended, but Python code is also compatible with Python 2.7.

Execution of CARLA using Docker

Run CARLA Server

In the first terminal, execute the following command to start the CARLA server.

$ docker run --runtime=nvidia --rm -p 2000-2002:2000-2002 -e NVIDIA_VISIBLE_DEVICES=0 carlasim/carla:0.8.4

Run Python Client

On another terminal, execute the following command to start the Python client.
Here, we start manual_control.py which displays depth and semantic segmentation image in RGB image.

$ cd ~/carla-0.8.4/PythonClient
$ ./manual_control.py --autopilot

The second line can be omitted as follows.

$ ./manual_control.py -a


To obtain the output added Lidar image as the first image, execute the following command.

$ ./manual_control.py --autopilot --lidar

Summary

We showed you how to set up CARLA using Docker.