文章目录
笔者台式机
CPU:i9-9900k
显卡:RTX2070S 8G
内存:16G
系统:ubuntu18.04
全程可以参照一下官方编译文档
0、端口配置
sudo iptables -I INPUT -p tcp --dport 2000 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 2001 -j ACCEPT
sudo 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
二、安装ubuntu18.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
pip2 install --user distro &&
pip3 install --user distro
#######################################
【如果前面安装失败失败,将电脑的软件源更换,并更新】
sudo gedit /etc/apt/sources.list
下面软件源任选其一,将其复制,粘贴到sources.list,将原来的内容覆盖
# 中科大镜像源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# 清华镜像源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# 阿里镜像源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
# 163镜像源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
然后更新
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
##############若无问题,进行第三步#########################
三、安装clang和LLVM’s libc++版本
我们要保证CARLA和它的引擎UNREALENGINE用的是一个版本的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和账号
【注册GitHub账号】
相信大家都有GitHub账号,就不详细讲解了。
【注册UnrealEngine账号】
1、进入网页www.unrealengine.com进行注册
2、接着登录,单击网站标题栏中的用户名,然后选择个人选项。
3、从菜单中选择连接的帐户。
4、单击GitHub图标下方的连接按钮。
笔者已经关联过了。
5、查看《虚幻引擎最终用户许可协议》并选中对应复选框接受该协议,然后单击关联您的帐户按钮。
6、登录现有GitHub帐户
7、单击授权按钮,完成关联流程
8、在进行下一步之前,进入https://github.com/EpicGames - Connect to preview 来查看你是否能看到一个叫做UnrealEngine的repo,如果能,说明你关联成功了。
五、安装UnrealEngine引擎
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
查看引擎是否能运行
cd ~/UnrealEngine_4.24/Engine/Binaries/Linux && ./UE4Editor
六、安装aria2加快carla的安装
sudo apt-get install aria2
七、下载carla并安装
cd ~
git clone https://github.com/carla-simulator/carla
(建议使用码云gitee,大小为100+M )
cd ~/carla
./Update.sh
八、添加环境变量
把UnrealEngine的路径加到bashrc里面
export UE4_ROOT=~/UnrealEngine_4.24
或者
gedit ~/.bashrc
将下面的这行语句放入文件末尾
export UE4_ROOT=~/UnrealEngine_4.24
然后使生效
source ~/.bashrc
九、编译
客户端
make PythonAPI
【提示缺什么模块就用pip3 insall XXX安装的模块该模块,比如pip3 install numpy】
服务器:
make launch
十、测试
打开终端,启动引擎
cd ~/carla/Unreal/CarlaUE4
~/UnrealEngine_4.24/Engine/Binaries/Linux/UE4Editor "$PWD/CarlaUE4.uproject"
然后按下Alt+P 或者点正上方工具图标播放
另外打开一个终端
cd ~/carla/PythonAPI/examples
python3 client_bounding_boxes.py