Carla自学整理——在Windows环境下构建Carla

本文参考CARLA官方文档中“Windows Build”板块进行批注、重点梳理与一些错误的解决方法,与官方文档相互补充,因此建议二者对照阅读。

构建之前的准备

系统要求:

1、165GB磁盘空间
2、2000和2001端口未被防火墙或任何其它应用程序阻止
(如果被占用则找到两个没被占的,但要注意以后运行API时要写一下端口,或直接改一下API代码中的默认端口)

第2点具体如何检查?
在cmd中输入

netstat -an | find "端口号"

 没有查询出任何信息(即无反馈),则该端口处于闲置状态

 另:原文档中此处有一个warning,先看看什么情况,以后补上

软件要求

1、次要安装

(1)CMake:Download CMake(下载Installer版本,安装时选"Add CMake to the system PATH to all users")
(2)Git:Git - Downloading Package(下载Standalone Installer版本,选一下"Add a Git BashProfile to WIndows Terminal")
(3)Make:Make for Windows(下载Complete package, except sources的Setup,一直点确认)
(4)7-Zip:7-Zip
(5)Python3 x64:Download Python | Python.org(若有安装x32版本,建议卸载)

最后建议检查一下上述程序是否均在环境路径中!特别是7-Zip!

①添加环境路径方式:
控制面板—系统和安全—系统—高级系统设置—环境变量—系统变量中找到Path点编辑—进行更改,选择到相应软件的bin文件夹

②检查环境路径:
按上述方式检查/cmd输入

"软件名" --version

若返回软件的版本号,即添加成功

2、Python依赖项

(1)在cmd中用此代码查询Python3的版本,需要在20.3以上

pip3 -V                       # 查询版本
pip3 install --upgrade pip    # 版本不够,进行升级

(2)安装两个Python依赖项

pip3 install --user setuptools
pip3 install --user wheel

可能遇见的问题:

Error1:"Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: setuptools in c:\users\72940\appdata\local\programs\python\python39\lib\site-packages (56.0.0)
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))) - skipping"

解决方法:在代码后面加" --trusted-host pypi.tuna.tsinghua.edu.cn"

Error2:"WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/wheel/"

解决方法:代码后加"-i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com"或其它镜像网站

Error3:安装后出现"WARNING: The script wheel.exe is installed in 'C:\Users\72940\AppData\Roaming\Python\Python39\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location."

解决方法:不知道必不必要,把该路径加入环境路径即可

3、主要安装 

(1)Visual Studio 2019:Download Visual Studio 2019 Web Installer / ISO (Community / Professional / Enterprise)
找到Visual Studio Community 2019下载
STEP1:建议卸载其它vs版本——在cmd中进入Program Files (x86)\Microsoft Visual Studio\Installer中含有InstallCleanup.exe的文件夹输入指令。

.\InstallCleanup.exe -full

STEP2:在vs安装程序中,点使用C++的桌面开发,右侧安装详细信息中选上"Windows 11 SDK";点.NET的桌面开发,右侧选上".NET Framework 4.6.2开发工具",安装即可。

(2)UE:
STEP0:建议先《科学上网》,然后cmd中输入(也可以不执行这步,但可能会慢些)

git config --global https.proxy 'http://127.0.0.1:1080'

STEP1:之后cmd进入一个文件夹(建议直接在D盘里) ,输入

git clone --depth 1 -b carla https://github.com/CarlaUnreal/UnrealEngine.git

STEP2:进入刚刚克隆下来的UE4文件夹(输入一下代码可进入)

git checkout d40ec35474e8793b4eea60dba6c4f051186e458e

分别输入:

Setup.bat
GenerateProjectFiles.bat

若Setup.bat运行出现403报错,可以参考这篇文档Upcoming Disruption of Service Impacting Unreal Engine Users on GitHub - Announcements - Epic Developer Community Forums

若Setup.bat运行速度极慢,可以尝试:

        记事本打开Setup.bat,找到set PROMPT_ARGUMENT=--prompt这一行,后面加上

"--threads=20  --proxy=18.65.19.160",分别是增加下载线程(threads),增加使用代理下载。

        此处的代理18.65.19.160是查询http://cdn.unrealengine.com的IP地址,找到其中能ping通的IP进行设置,有时会变,建议大家自行去IP查询网上查,并找到一个能ping通的IP。

此处参考:UE4/5源码执行Setup下载缓慢问题 - 知乎 (zhihu.com)icon-default.png?t=N7T8https://zhuanlan.zhihu.com/p/610021606

(我是0.0几的MiB/s,进行了上述操作后到了6MiB/s,这个速度我是非常满意了!按以前的速度根本下不完!)

若Setup.bat下载到99%后速度变为0,可以尝试将文件夹名改短(6个字符以内),参考:

UE4源码编译setup.bat运行之后一直卡在99%,已解决_ue setup卡在99-优快云博客icon-default.png?t=N7T8https://blog.youkuaiyun.com/weixin_43203134/article/details/118353838

STEP3:
在刚刚克隆下来的文件夹(UnrealEngine)中打开UE4.sln文件
②在vs上面选Development Editor、Win64、UnrealBuildTool
③打开解决方案资源管理器(在视图中),右键单击“UE4”并选择“生成”(需要一些时间)
④添加环境变量(用户变量&系统变量),变量名:UE4_ROOT,变量路径:D:\UnrealEngine(即刚刚克隆下来的文件夹)
⑤可以尝试打开一下Engine\Binaries\Win64中的UE4Editor(第一次很慢很慢,会在45%卡蛮久,等待……)


恭喜! 构建之前的准备已结束,重启一下电脑吧~


构建CARLA 

克隆 CARLA 存储库

在cmd进入任何一个地方(建议还是D盘)输入:

git clone https://github.com/carla-simulator/carla

发现下载速度很慢,只有几十kb/s,上网搜试了好几种方法,发现库太大码云用不了,又有几个几年前好用的翻墙网站停运了,最后发现这两种方法还不错:

1、shallow下载+gitclone:将代码换成:

git clone https://gitclone.com/github.com/carla-simulator/carla --depth 1

2但是由于Carla克隆库实在太大,用法1速度可以达到100kb/s-1mb/s(不太稳定),下载起来还是太慢不满意,于是我尝试使用Pigcha加速器,非常好用,能达到5mb/s,但是需要一点小费用,我买的月卡,嫌法1慢的可以试一试(代码不用带gitclone.com,但是--depth 1还是建议加)

下载地址:Pigcha加速器

安装注册后选一个节点,直接加速即可

获得资产 

STEP1:有两种方法——
A:cmd在carla文件夹中输入:

 Update.bat

B:在文件夹carla\Util中的文档ContentVersion中替换网址后,复制下载(如果A方法太慢的话建议尝试这一种),压缩包复制到Unreal\CarlaUE4\Content\Carla

STEP2:创建carla\Unreal\CarlaUE4\Content\Carla路径,在cmd中打开并输入:

tar -xvzf <assets_file_name>.tar.gz.tar -C C:\path\to\carla\Unreal\CarlaUE4\Content\Carla

构建CARLA 

STEP1:编译Python API客户端
开始栏搜索x64进入x64 Native Tools Command Prompt for VS 2019
进入carla文件夹,输入:

make PythonAPI

可能错误1:"CMake Error: The source directory "C:/Carla/carla/Build/rpclib-src" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. "

解决方案:在carla/Util/InstallersWin中记事本打开install_lib,找"set ZLIB_VERSION=",把版本号改成1.3,之后再运行make PythonAPI

可能错误2:"Failed to find XercesC (missing: XercesC_VERSION)"

解决方案:同1一样修改XercesC 3.2.4版本,再去carla/Util/BuildTools的Setup中修改3.2.4版本

可能错误3:安装有问题

解决方案:点开carla/Util/InstallersWin中对应的bat文件,找到地址自己安装。过程中大概可以使用make clean清除缓存。
几个常见易出错的包的安装地址和详情可以看一看这篇文章【Carla】Windows编译版安装-超详细版教程 - 知乎

处理完错误后,再执行make PythonAPI,直至carla\PythonAPI\carla下出现dist文件夹,且dist中有两个文件(一个.egg,一个.whl),则可以进行下一步。

STEP2:x64进入dist文件夹,执行:

pip3 install carla-0.9.12-cp37-cp37m-win_amd64.whl

 STEP3:x64在carla文件夹下,执行:

make launch

期间的请求选同意即可 

(启动过程会很慢,卡在45%和95%很久都有可能,等待即可)

后天我会尝试安装一下,到时候遇到的任何新问题都会在这里进行修改和补充,大家互相帮助,一起填坑!

最后,推荐另一篇蛮详细的参考文章,遇到困难的uu可以看一看

Windows从源码编译Carla0.9.13(沉浸式安装) - 知乎鉴于从CARLA0.9.10-0.9.14 Windows/Linux,每次由于新的框架,或者换新电脑等情况,已经装了N次了。在这里写一个记录一下详细的安装过程,方便自己以后再次安装,顺便分享给大家,祝大家能一遍成功! 一、硬件要求…icon-default.png?t=N7T8https://zhuanlan.zhihu.com/p/668593156

### Carla on Windows Setup and Configuration For setting up CARLA on a Windows system, one can follow these guidelines which ensure that all necessary components are correctly installed to facilitate an efficient simulation environment. #### Prerequisites Installation Before installing CARLA, it is essential to have several prerequisites set up. These include having Python (preferably version 3.7 or higher), Git for cloning repositories, and Visual Studio Community Edition along with C++ build tools as they provide the compilers required by Unreal Engine[^2]. #### Installing Unreal Engine CARLA relies heavily upon Unreal Engine for its graphical rendering capabilities. Downloading and installing Unreal Engine through the Epic Games Launcher ensures compatibility between CARLA versions and their corresponding supported UE4 releases. After installation, configure the engine path within the `Setup.bat` file located inside the CARLA folder so that scripts know where to find the executable during compilation processes. #### Cloning CARLA Repository Using Git Bash or Command Prompt, clone the official CARLA repository using HTTPS or SSH keys provided at GitHub: ```bash git clone https://github.com/carla-simulator/carla.git cd carla ``` Ensure branches match those specified in documentation since different CARLA tags may require specific UE4 builds. #### Building CARLA Once cloned successfully, run the following batch script found under the root directory of your local copy of the CARLA repo: ```batch LaunchBuildWindows.bat ``` This command will automatically download dependencies like Boost libraries while also compiling source files into binaries ready for execution once completed without errors. #### Running CARLA Simulator After building completes, start the simulator via double-clicking `CarlaUE4.exe`. If running headlessly from another machine over network connections such as described earlier about Linux PCs equipped GPUs but no monitors attached; refer back to remote desktop solutions compatible with DirectX APIs used here instead of X11 forwarding methods applicable elsewhere. --related questions-- 1. What are some common issues encountered when configuring CARLA on Windows? 2. How does one integrate custom sensors into the CARLA framework after successful setup? 3. Can you explain how to use Docker containers alongside native installations for better portability across platforms including Windows? 4. In what ways do hardware specifications impact performance metrics observed within simulated environments built around CARLA?
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值