Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.uasset filter=lfs diff=lfs merge=lfs -text
*.umap filter=lfs diff=lfs merge=lfs -text
90 changes: 61 additions & 29 deletions Docs/Install.md

Large diffs are not rendered by default.

133 changes: 42 additions & 91 deletions Docs/Install_Ubuntu.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,71 @@
# Installing Carla on Ubuntu 20.04
This guide is for installing Carla 0.9.13 (along with Unreal Engine 4.26) build on Ubuntu 20.04.5 (Focal Fosca). It is largely based on [this tutorial](https://carla.readthedocs.io/en/latest/build_linux/) by Carla, and can be thought of as a shorter updated of it specifically for Ubuntu 20.04 and DReyeVR. Check out the original tutorial tutorial for more detailed explanations of some the commands. Commands themselves, however, slightly differ from the original version.

## Part One: Prerequisites
- **Ubuntu 20.04**
- **130 GB disk space.** Carla will take around 31 GB and Unreal Engine will take around 91 GB so have about 130 GB free to account for both of these plus additional minor software installations.
- **An adequate GPU**. CARLA aims for realistic simulations, so the server needs at least a 6 GB GPU although 8 GB is recommended. A dedicated GPU is highly recommended for machine learning.
- **Two TCP ports and good internet connection.** 2000 and 2001 by default. Make sure that these ports are not blocked by firewalls or any other applications.
# Installing Carla on Ubuntu 20.04+
This guide covers the Ubuntu-specific requirements for installing Carla 0.9.13 with DReyeVR. For the general installation steps, see [Install.md](Install.md).

## Prerequisites
- **Ubuntu 20.04 or newer**
- **130 GB disk space.** Carla will take around 31 GB and Unreal Engine will take around 91 GB so have about 130 GB free to account for both of these plus additional minor software installations.
- **An adequate GPU.** CARLA aims for realistic simulations, so the server needs at least a 6 GB GPU although 8 GB is recommended. A dedicated GPU is highly recommended for machine learning.
- **Two TCP ports and good internet connection.** 2000 and 2001 by default. Make sure that these ports are not blocked by firewalls or any other applications.
- **IMPORTANT: Proprietary drivers installed.** Please make sure that you are using the latest stable version of proprietary drivers (for instance, Nvidia). Check [this guide](https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-20-04-focal-fossa-linux) for installing and updating the Nvidia driver on Ubuntu 20.04.

## Installing software requirements
Please use the following set of commands to install the necessary software packages.
**Note**: you might want to go over each of the listed packages separately to ensure that each was installed correctly to avoid issues during the installation. Later on, the missing packages will be harder to track.
```bash
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main"
sudo apt-get install build-essential clang-8 lld-8 g++-7 cmake ninja-build libvulkan1 python-dev python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-8/bin/clang++ 180 &&
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-8/bin/clang 180
```
## Software requirements

#### Clang issue:
One of the issues specific to Ubuntu 20.04 installation is the **clang** compiler. The CARLA team uses clang-8 and LLVM's libc++. while clang-8 can be installed on Ubuntu 20.04, it is rather outdated and does not catch some of the existing bugs within carla. If you want to use a different version of clang and libc++, follow the instructions below:
<details>
<summary>how to use a different clang version</summary>
Uninstall clang-8 (installed if you executed the previous command):
### Clang compiler
The CARLA team originally uses clang-8 which is outdated and not available on Ubuntu 20.04+. We have tested successfully with **clang-14** (the default on Ubuntu 22.04)

```bash
sudo apt-get remove clang-8 lld-8
sudo rm /usr/bin/clang /usr/bin/clang++
sudo apt-get install build-essential clang lld g++-7 cmake ninja-build libvulkan1 python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
```

Install version 10:
```bash
sudo apt-get install clang-10 lld-10
```
Set up clang and clang++ commands:
### Python version
**IMPORTANT:** We highly recommend using **Python 3.7** for building the PythonAPI. Newer Python versions (3.8+) can cause issues when compiling Boost 1.72.0.

You can use [pyenv](https://github.com/pyenv/pyenv) to manage Python versions:
```bash
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-10/bin/clang++ 180 &&
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-10/bin/clang 180
# Install pyenv (if not installed)
curl -fsSL https://pyenv.run | bash

# Install Python 3.7.9
pyenv install 3.7.9

# Set it as local version for the carla directory (run this inside the carla repo)
pyenv local 3.7.9
```
Create a symbolic link that would tell the system to use version 10 whenever it encounters `usr/bin/clang-8` in one of the CARLA setup or installation scripts:

If using pyenv, you may need to create a symlink for the Python headers:
```bash
sudo ln -s /usr/bin/clang /usr/bin/clang-8
sudo ln -s /usr/bin/clang++ /usr/bin/clang++-8
ln -s ~/.pyenv/versions/3.7.9/include/python3.7m ~/.pyenv/versions/3.7.9/include/python3.7
```
</details>
<br>


### Python dependencies
Version 20.3 or higher of **pip3** is required. To check if you have a suitable version, run the following command:
Version 20.3 or higher of **pip3** is required. To check if you have a suitable version, run:
```bash
pip3 -V
```
If you need to upgrade:
```bash
pip3 install --upgrade pip
```
You might be prompted to add the directory of the newer version to PATH. If yes, do so.

You must install the following Python dependencies:
# If using pyenv, you may need to specify the full path:
~/.pyenv/versions/3.7.9/bin/python3.7 -m pip install --upgrade pip
```
pip3 install --user -Iv setuptools==47.3.1 &&
pip3 install --user distro &&
pip3 install --user wheel auditwheel &&

Install the required Python dependencies:
```bash
pip3 install --user -Iv setuptools==47.3.1
pip3 install --user distro
pip3 install --user wheel auditwheel
pip3 install nose2
```
Some of the installation and setup scripts use the deprecated **python** command. One way to avoid the issues caused by this is with a symbolic link:
```
sudo ln -s /usr/bin/python3 /usr/bin/python
```
If your file is named other than **python3**, substitute python 3 for your python version.
<br>

### Unreal Engine
This section does not require updates or modifications. Please follow the exact steps from the corresponding section of [this tutorial](https://carla.readthedocs.io/en/latest/build_linux/).
<br>

## Part Two: Build CARLA
**Note**: downloading aria2 with `sudo apt-get install aria2` will speed up the following commands.
## Troubleshooting

Clone the CARLA repository:
```bash
git clone https://github.com/carla-simulator/carla -b 0.9.13
```
Once download is finished, from the new **carla** directory, run
### Boost compilation fails with `pyconfig.h` not found
This usually happens when Python headers are not found. If using pyenv:
```bash
Update.sh
ln -s ~/.pyenv/versions/3.7.9/include/python3.7m ~/.pyenv/versions/3.7.9/include/python3.7
```

Navigate to the **carla** directory. Open **./Util/BuildTools/Setup.sh** and replace `XERCESC_VERSION=3.2.3` (line 428) with `XERCESC_VERSION=3.2.4`. Next, open **./Util/BuildTools/BuildOSM2ODR.sh**, and replace all instances of `xerces-c-3.2.3` with `xerces-c-3.2.4`.


Follow the rest of the instructions from the [tutorial](https://carla.readthedocs.io/en/latest/build_linux/).


Now that you have a working CARLA 0.9.13 build, go back to the [DReyeVR installation guide](https://github.com/HARPLab/DReyeVR/blob/main/Docs/Install.md) and follow the rest of the steps to install DReyeVR on top of it.

- **READ THIS FIRST (Linux)**: You might run into a problem when compiling Boost 1.72.0 (required by `LibCarla`).
<details>

<summary> Show instructions to get Anaconda working on Linux </summary>

- ```bash
# find anaconda install:
which python3
... PATH/TO/ANACONDA/envs/carla/bin/python3 # example output

# go to carla/install dir from here
cd PATH/TO/ANACONDA/envs/carla/include
## Next Steps

# create a symlink between python3.7 -> python3.7m
ln -s python3.7m python3.7
```
Install `boost_1_72_0.tar.gz` manually from https://github.com/jerry73204/carla/releases/tag/fix-boost and place file in `Build/boost_1_72_0.tar.gz`
Open `Util/BuildTools/Setup.sh` (or `Util/BuildTools/Setup.bat` on Windows)
Find the section named `Get boost` includes and comment out the `wget` lines.
Now when you `make LibCarla` again, the `boost` errors should be resolved.
- For more information see the bottom of this [SO post](https://stackoverflow.com/questions/42839382/failing-to-install-boost-in-python-pyconfig-h-not-found)
</details>
Once you have installed the Ubuntu requirements, follow the general installation steps in [Install.md](Install.md).
200 changes: 200 additions & 0 deletions Util/BuildTools/BuildCarlaUE4.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
@echo off
setlocal enabledelayedexpansion

rem BAT script that creates the binaries for Carla (carla.org).
rem Run it through a cmd with the x64 Visual C++ Toolset enabled.

set LOCAL_PATH=%~dp0
set FILE_N=-[%~n0]:

rem Print batch params (debug purpose)
echo %FILE_N% [Batch params]: %*

rem ============================================================================
rem -- Parse arguments ---------------------------------------------------------
rem ============================================================================

set BUILD_UE4_EDITOR=false
set LAUNCH_UE4_EDITOR=false
set REMOVE_INTERMEDIATE=false
set USE_CARSIM=false
set USE_CHRONO=false
set CARSIM_STATE="CarSim OFF"
set CHRONO_STATE="Chrono OFF"

:arg-parse
echo %1
if not "%1"=="" (
if "%1"=="--build" (
set BUILD_UE4_EDITOR=true
)
if "%1"=="--launch" (
set LAUNCH_UE4_EDITOR=true
)
if "%1"=="--clean" (
set REMOVE_INTERMEDIATE=true
)
if "%1"=="--carsim" (
set USE_CARSIM=true
)
if "%1"=="--chrono" (
set USE_CHRONO=true
)
if "%1"=="-h" (
goto help
)
if "%1"=="--help" (
goto help
)
shift
goto arg-parse
)

if %REMOVE_INTERMEDIATE% == false (
if %LAUNCH_UE4_EDITOR% == false (
if %BUILD_UE4_EDITOR% == false (
goto help
)
)
)

rem Get Unreal Engine root path
if not defined UE4_ROOT (
set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine"
set VALUE_NAME=InstalledDirectory
for /f "usebackq tokens=1,2,*" %%A in (`reg query !KEY_NAME! /s /reg:64`) do (
if "%%A" == "!VALUE_NAME!" (
set UE4_ROOT=%%C
)
)
if not defined UE4_ROOT goto error_unreal_no_found
)
if not "%UE4_ROOT:~-1%"=="\" set UE4_ROOT=%UE4_ROOT%\

rem Force Visual Studio 2019 toolset to avoid C4756 errors with VS2022 toolset
set VCToolsVersion=14.29.30133

rem Set the visual studio solution directory
rem
set UE4_PROJECT_FOLDER=%ROOT_PATH:/=\%Unreal\CarlaUE4\
pushd "%UE4_PROJECT_FOLDER%"

rem Clear binaries and intermediates generated by the build system
rem
if %REMOVE_INTERMEDIATE% == true (
rem Remove directories
for %%G in (
"%UE4_PROJECT_FOLDER%Binaries",
"%UE4_PROJECT_FOLDER%Build",
"%UE4_PROJECT_FOLDER%Saved",
"%UE4_PROJECT_FOLDER%Intermediate",
"%UE4_PROJECT_FOLDER%Plugins\Carla\Binaries",
"%UE4_PROJECT_FOLDER%Plugins\Carla\Intermediate",
"%UE4_PROJECT_FOLDER%.vs"
) do (
if exist %%G (
echo %FILE_N% Cleaning %%G
rmdir /s/q %%G
)
)

rem Remove files
for %%G in (
"%UE4_PROJECT_FOLDER%CarlaUE4.sln"
) do (
if exist %%G (
echo %FILE_N% Cleaning %%G
del %%G
)
)
)

rem Build Carla Editor
rem
where python >nul 2>nul
if %errorlevel% neq 0 (
echo %FILE_N% WARNING: Python not found in PATH, skipping CarSim config
goto skip_carsim_config
)

if %USE_CARSIM% == true (
call python "%ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py" -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" -e
set CARSIM_STATE="CarSim ON"
) else (
call python "%ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py" -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"
set CARSIM_STATE="CarSim OFF"
)

:skip_carsim_config
if %USE_CHRONO% == true (
set CHRONO_STATE="Chrono ON"
) else (
set CHRONO_STATE="Chrono OFF"
)
set OPTIONAL_MODULES_TEXT=%CARSIM_STATE% %CHRONO_STATE%
echo %OPTIONAL_MODULES_TEXT% > "%ROOT_PATH%Unreal/CarlaUE4/Config/OptionalModules.ini"

if %BUILD_UE4_EDITOR% == true (
echo %FILE_N% Building Unreal Editor...

call "%UE4_ROOT%Engine\Build\BatchFiles\Build.bat"^
CarlaUE4Editor^
Win64^
Development^
-WaitMutex^
-FromMsBuild^
"%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"
if errorlevel 1 goto bad_exit

call "%UE4_ROOT%Engine\Build\BatchFiles\Build.bat"^
CarlaUE4^
Win64^
Development^
-WaitMutex^
-FromMsBuild^
"%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"
if errorlevel 1 goto bad_exit
)

rem Launch Carla Editor
rem
if %LAUNCH_UE4_EDITOR% == true (
echo %FILE_N% Launching Unreal Editor...
call "%UE4_ROOT%\Engine\Binaries\Win64\UE4Editor.exe"^
"%UE4_PROJECT_FOLDER%CarlaUE4.uproject"
if %errorlevel% neq 0 goto error_build
)

goto good_exit

rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================

:help
echo Build LibCarla.
echo "Usage: %FILE_N% [-h^|--help] [--build] [--launch] [--clean]"
goto good_exit

:error_build
echo.
echo %FILE_N% [ERROR] There was a problem building CarlaUE4.
echo %FILE_N% Please go to "Carla\Unreal\CarlaUE4", right click on
echo %FILE_N% "CarlaUE4.uproject" and select:
echo %FILE_N% "Generate Visual Studio project files"
echo %FILE_N% Open de generated "CarlaUE4.sln" and try to manually compile it
echo %FILE_N% and check what is causing the error.
goto bad_exit

:good_exit
endlocal
exit /b 0

:bad_exit
endlocal
exit /b %errorlevel%

:error_unreal_no_found
echo.
echo %FILE_N% [ERROR] Unreal Engine not detected
goto bad_exit
Loading