文章目录

  • ​​环境准备​​
  • ​​基础软件安装​​
  • ​​Python依赖​​
  • ​​创建carla python虚拟环境​​
  • ​​安装CARLA​​
  • ​​下载最新预编译库​​

  • ​​启动 CARLA 服务器​​

环境准备

基础软件安装

sudo apt-get update &&
sudo apt-get install wget software-properties-common &&
sudo add-apt-repository ppa:ubuntu-toolchain-r/test &&
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - &&
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" &&
sudo apt-get update
sudo apt-get install build-essential clang-8 lld-8 cmake ninja-build libvulkan1 python python-pip 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

Python依赖

创建carla python虚拟环境

防止损坏系统相关python依赖软件

conda create -n carla python=3.7
conda activate carla
pip install --user -Iv setuptools==47.3.1 &&
pip install --user distro &&
pip install --user wheel auditwheel
pip install --user pygame numpy

安装CARLA

下载最新预编译库

6.2G,比较大,可以耐心等待,如果想自己在本机编译,参考链接:​​Linux build​

wget https://carla-releases.s3.eu-west-3.amazonaws.com/Linux/Dev/CARLA_Latest.tar.gz
mkdir CARLA
tar -zxvf CARLA_Latest.tar.gz -C CARLA
cd CARLA
./ImportAssets.sh

启动 CARLA 服务器

cd ../../.. # 回到根目录
./CarlaUE4.sh

此时会弹出页面(旁观者画面):

CARLA——基于Ubuntu18.04安装CARLA Simulator_python

注意,需要在刚使用Conda建立的​python3.7​虚拟环境中运行

cd PythonAPI/examples
python -m pip install -r requirements.txt # Support for Python2 is provided

安装Python包:

cd PythonAPI/carla/dist
ls # 查看python包
pip install carla-0.9.13-cp37-cp37m-manylinux_2_27_x86_64.whl

打开一个终端运行:

# Terminal A
conda activate carla
python generate_traffic.py

再打开一个终端运行:

# Terminal B
conda activate carla
cd CARLA/PythonAPI/examples
python manual_control.py

现在就可以开始你的开车之旅啦~

CARLA——基于Ubuntu18.04安装CARLA Simulator_g++_02