Ubuntu 18.04 安装CARLA

Ubuntu 18.04 安装CARLA

  • 环境准备
    • 安装NVIDIA驱动(显卡 K5000)
    • 安装vulkan-sdk
    • 端口配置
    • 依赖安装
  • 构建安装 Unreal Engine 4.24.(10G左右)
  • 构建CARLA
  • 构建PythonAPI
  • 测试例子
  • 遇到的问题

https://carla.readthedocs.io/en/latest/build_linux/

环境准备

Ubuntu 18.04 安装CARLA_第1张图片

安装NVIDIA驱动(显卡 K5000)

安装NVIDIA驱动推荐版本:sudo ubuntu-drivers autoinstall

安装vulkan-sdk

Ubuntu 18 安装 vulkan-sdk

wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-bionic.list http://packages.lunarg.com/vulkan/lunarg-vulkan-bionic.list
sudo apt update
sudo apt install vulkan-sdk

端口配置

iptables -I INPUT -p tcp --dport 2000 -j ACCEPT
iptables -I INPUT -p tcp --dport 2001 -j ACCEPT
iptables-save

依赖安装

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/$(lsb_release -c --short)/ llvm-toolchain-$(lsb_release -c --short)-8 main" &&
sudo apt-get update
  • Ubuntu 18.04 额外的依赖
sudo apt-get install build-essential clang-8 lld-8 g++-7 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 &&
pip2 install --user setuptools &&
pip3 install --user setuptools 
  • 修改默认 clang 版本.
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
  • 注册 GitHub 和 UE 账户, 并将他们链接起来 (可自行百度).
  • 安装 git. 克隆的时候用你与UE链接的github帐号
sudo apt install git

构建安装 Unreal Engine 4.24.(10G左右)

git clone --depth=1 -b 4.24 https://github.com/EpicGames/UnrealEngine.git ~/UnrealEngine_4.24
cd ~/UnrealEngine_4.24
./Setup.sh && ./GenerateProjectFiles.sh && make
  • 打开 UE Editor 检测是否工作正常.
cd ~/UnrealEngine_4.24/Engine/Binaries/Linux && ./UE4Editor

构建CARLA

  • 克隆 CARLA.
git clone https://github.com/carla-simulator/carla
  • 获取 CARLA 资源.
cd ~/carla
./Update.sh
  • 注意为了防止biuld过程出现问题,最好先备份一份 update之后carla文件夹10G左右 重新下载需要很久时间
 cp ~/carla ~/carla-bak
  • 设置环境变量(也可在~/.bashrc最后添加)
export UE4_ROOT=~/UnrealEngine_4.24
  • 启动CARLA-UNReal
make launch

构建PythonAPI

make PythonAPI 

测试例子

cd PythonAPI/examples
python3 automatic_control.py

Ubuntu 18.04 安装CARLA_第2张图片

遇到的问题

  1. 记得一定要开启UNReal
    Ubuntu 18.04 安装CARLA_第3张图片
    如果没有点击play的话,会出现如下错误.
INFO: listening to server 127.0.0.1:2000
Example of automatic vehicle control from client side.
Traceback (most recent call last):
  File "automatic_control.py", line 846, in 
    main()
  File "automatic_control.py", line 839, in main
    game_loop(args)
  File "automatic_control.py", line 687, in game_loop
    world = World(client.get_world(), hud, args)
RuntimeError: time-out of 4000ms while waiting for the simulator, make sure the simulator is ready and connected to 127.0.0.1:2000
  1. 在构建carla的时候不能用root权限, 否则 make launch 的时候可能会出错
  2. 如果在构建carla之前没有把端口2000和2001开放的话,需要开放端口后重新构建
  3. 在运行example之前需要把PythonAPI/examples/requirements.txt 里的包用pip3安装, 因为我们用的是python3运行例子
  4. 重启 (reboot) 可以帮你解决很多问题. 环境配置好之后记得重启 重启.
  5. 遇到问题可以查看一下https://carla.readthedocs.io/en/stable/faq/
    比如: 运行case是FPS 过低:
    Why do I have very low FPS when running the server in Unreal Editor?
    UE4 Editor goes to a low performance mode when out of focus. It can be disabled in the editor preferences. Go to “Edit->Editor Preferences->Performance” and disable the “Use Less CPU When in Background” option.

你可能感兴趣的:(自动驾驶)