To follow this project tutorial series, you will need to set up your local machine or device to adequately run the program without any hassle.
This tutorial guides you through getting and installing the project requirements, and environment setup needed to fully configure and set up your local machine to code, train, and test an autonomous self-driving car using Python programming language and CARLA.
CARLA requires a 4GB minimum GPU to effectively run a highly realistic environment in the same way you would need a higher GPU to render a high graphic game engine.
Generally, we advise you to get a dedicated GPU for all Artificial Intelligence related projects and tutorials like machine learning to get the best results.
On the client-side, you should install the latest stable and available Python Programming Language version that is best compatible with the latest stable and available version of CARLA.
Python is needed to access the API via the command line.
For your local computer requirement, any 64-bits OS should run CARLA and Python. However, since release 0.9.9, CARLA cannot run in 16.04 Linux systems with default compilers.
As a result, if this is your situation, you should upgrade your Linux machine to work with CARLA.
Other requirements include two essential Python modules: Pygame to create graphics directly with Python, and Numpy for great calculus.
Another requirement to get is the open-cv library, which comes in handy when we want to use the camera module.
You will need a good internet connection.
You will also need a fair knowledge of how to use the command-line of your preferred OS platform.
Step 1: Set up a working python environment
This tutorial series requires you to already have a current version of Python 3 installed. The version of Python used for this tutorial series is Python 3.7.x.
If you do not already have a version of python 3 installed, use the link to get and set up a Python working environment on your device.
You will also need a Python package manager to get some additional modules installed. You can either use the pip package manager or anaconda package manager. This tutorial uses pip.
Using the pip package manager, run the command below to install the pygame and numpy Python packages.
pip install --user pygame numpy
Next, run the command below to install open-cv for the camera module.
pip install opencv-python
Step 2: Download and Setup CARLA
There are two ways of getting CARLA: The Debian installation and the Package installation.
The Debian installation is the easiest way to get the latest release in Linux.
On the other hand, the Package installation is useful to get either a specific release or the Windows version of CARLA.
We will be using the package installation method.
To download a version of CARLA, visit the official Github repository and select the latest stable version. At the time of making this tutorial, the latest version is
CARLA_0.9.10.tar.gzfor Linux Ubuntu OS or
CARLA_0.9.10.zipfor Windows OS.
Download additional assets. For every version released, there are additional assets and maps.
For instance, the Linux Ubuntu version
CARLA_0.9.10.zipfor Windows OS comes with AdditionalMaps_0.9.10.zip.
These are stored separately to reduce the size of the build, so they can only be run after these packages are imported.
After downloading, move the package to the import folder. On Windows, directly extract the package on the root folder. On Linux, run the commands below on your command-line to extract them:
> cd ~/carla > ./ImportAssets.sh
Step 3: Run CARLA to test installation and complete the environment setup
Open your command prompt/terminal and navigate to the main CARLA folder.
Run the following command to execute the package file and start the simulation:
# Linux: > ./CarlaUE4.sh # Windows: > CarlaUE4.exe
If everything is done right, a window containing a view over the city will pop up. This is the spectator view. To fly around the city use the mouse and WASD keys (while clicking).
This means that the server simulator (CARLA) is now running and waiting for a client (Python API) to connect and interact with the world.
With this, you are ready to code and run scripts for the autonomous self-driving car project.
In the meantime, you can spawn some life into the city using the following example:
While on the command line, navigate to the folder containing example scripts and run the command below.
> cd PythonAPI/examples
The package installation version does not require any update. This is because the content is bundled and as a result, tied to a specific version of CARLA.
This means that whenever there is a new version release, the GIT repository will be updated. But to run this latest or any other version, you have to delete the previous and install the one desired.
In the Debian installation, it is important for
CarlaUE4.sh to be accessed in
/opt/carla-simulator/bin/, instead of the main
This concludes the environment setup and installation process.
If you run into errors or unable to complete this tutorial, feel free to contact us anytime, and we will instantly resolve it. You can also request clarification, download this tutorial as pdf or report bugs using the buttons below.