本文记录在 Windows 环境下编译并运行 Colosseum / AirSim 插件的完整过程,包含 Visual Studio 2022 安装、Colosseum 编译、Eigen 依赖处理、UE5.6 兼容性修复,以及最终在 BlocksV2 中成功进入 Unreal Editor 并点击 Play 的全过程。 适合遇到 Colosseum_Eigen not properly initializedC4819 / C4127 / C2220LineBatcherPersistentLineBatcherTObjectPtr<APawn> 等问题的同学参考。


1. 环境说明

本文使用的通用环境如下:

系统:Windows 10 / Windows 11
Unreal Engine:UE 5.6
IDE:Visual Studio 2022
项目:Colosseum / AirSim
测试场景:Colosseum 自带 BlocksV2

建议使用如下目录结构:

<Workspace>
└── Colosseum
    ├── AirLib
    ├── PythonClient
    ├── Unreal
    │   ├── Plugins
    │   │   └── AirSim
    │   └── Environments
    │       └── BlocksV2
    └── build.cmd

后文统一使用:

<ColosseumRoot> = Colosseum 仓库根目录
<BlocksV2Root> = <ColosseumRoot>\Unreal\Environments\BlocksV2
<BlocksAirSimPlugin> = <BlocksV2Root>\Plugins\AirSim

例如:

<ColosseumRoot>\build.cmd
<BlocksV2Root>\BlocksV2.uproject
<BlocksAirSimPlugin>\Source\PawnSimApi.cpp

如果机器只有 C 盘,也可以将 Colosseum 放到用户目录下,例如:

%USERPROFILE%\Dev\Colosseum

不建议放到:

C:\Program Files
C:\Windows

因为这些目录更容易遇到权限问题。


2. 安装 Visual Studio 2022

Colosseum / AirSim 在 Windows 上需要 Visual Studio 2022 的 C++ 编译环境。

打开:

Visual Studio Installer

选择 Visual Studio 2022,点击:

Modify / 修改

2.1 勾选工作负载

Workloads / 工作负载 中勾选:

Desktop development with C++
使用 C++ 的桌面开发

2.2 勾选单个组件

Individual components / 单个组件 中建议勾选:

MSVC v143 C++ x64/x86 build tools
Windows 10 SDK 10.0.19041.0
.NET Framework 4.8 SDK
.NET Framework 4.8 Targeting Pack
.NET Framework 4.8.1 SDK
.NET Framework 4.8.1 Targeting Pack

.NET Framework 4.8 SDK.NET Framework 4.8.1 SDK 可以同时安装,不冲突。


3. 克隆 Colosseum

打开:

Developer Command Prompt for VS 2022

进入工作目录并克隆:

cd <Workspace>
git clone https://github.com/CodexLabsLLC/Colosseum.git
cd Colosseum

如果网络可以正常访问 GitHub,推荐直接递归克隆:

git clone --recursive https://github.com/CodexLabsLLC/Colosseum.git

如果没有递归克隆,也可以后续执行:

git submodule update --init --recursive

4. 第一次运行 build.cmd

进入 Colosseum 根目录:

cd <ColosseumRoot>
build.cmd

如果一切正常,脚本会编译 AirLib、复制依赖,并生成 Unreal 插件所需文件。


5. 报错一:Eigen 子模块缺失

5.1 报错现象

可能会遇到:

Setup Eigen dependency for AirLib
Submodule ExternalRepositories\Colosseum_Eigen not properly initialized.
Try running 'git submodule update --init'
Build failed!

5.2 原因

Colosseum 依赖 Eigen,但子模块没有被正确下载。

理论上可以执行:

git submodule update --init --recursive

但如果网络无法访问 GitHub,可能会出现:

Failed to connect to github.com port 443
Could not connect to server

或者子模块仓库无法访问。


6. 手动安装 Eigen 依赖

如果子模块无法下载,可以手动下载 Eigen 并放到指定位置。

6.1 下载 Eigen

下载 Eigen 3.4.0:

https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip

如果目标机器无法访问 GitLab,可以在其他网络环境下载后复制到目标机器。

6.2 解压并放置

解压后,需要将 Eigen 内容放到:

<ColosseumRoot>
└── ExternalRepositories
    └── Colosseum_Eigen
        ├── Eigen
        ├── unsupported
        ├── CMakeLists.txt
        └── ...

重点是这个路径必须存在:

<ColosseumRoot>\ExternalRepositories\Colosseum_Eigen\Eigen

不要放成:

<ColosseumRoot>\ExternalRepositories\Colosseum_Eigen\eigen-3.4.0\Eigen

否则多了一层目录,脚本仍然可能找不到 Eigen。

6.3 检查路径

cd <ColosseumRoot>
dir ExternalRepositories\Colosseum_Eigen\Eigen

如果可以看到类似内容:

Core
Dense
Geometry
LU
SVD

说明 Eigen 放置正确。


7. 报错二:C4819 / C2220

7.1 报错现象

重新运行:

build.cmd

可能会出现:

warning C4819: 该文件包含不能在当前代码页中表示的字符
error C2220: 以下警告被视为错误

常见文件包括:

AirLib\deps\eigen3\Eigen\src\Core\arch\Default\Half.h
AirLib\deps\eigen3\Eigen\src\Core\arch\Default\BFloat16.h

7.2 原因

中文 Windows 默认代码页可能不是 UTF-8,MSVC 读取 Eigen 源码时触发 C4819 警告。同时项目把 warning 当成 error,因此最终变成 C2220

7.3 解决方法

在同一个 Developer Command Prompt for VS 2022 窗口中执行:

cd <ColosseumRoot>
chcp 65001
set CL=/wd4819
build.cmd

其中:

chcp 65001

表示将当前命令行切换到 UTF-8。

set CL=/wd4819

表示告诉 MSVC 忽略 C4819 警告。


8. 报错三:C4127 / C2220

8.1 报错现象

压掉 C4819 后,可能继续出现:

warning C4127: 条件表达式是常量
error C2220: 以下警告被视为错误

8.2 解决方法

继续在同一个命令行窗口中执行:

cd <ColosseumRoot>
chcp 65001
set CL=/wd4819 /wd4127
set _CL_=/wd4819 /wd4127 /WX-
build.cmd

如果仍然有编码相关问题,可以使用:

cd <ColosseumRoot>
chcp 65001
set CL=/utf-8 /wd4819 /wd4127
set _CL_=/utf-8 /wd4819 /wd4127 /WX-
build.cmd

其中:

/wd4819

忽略 C4819

/wd4127

忽略 C4127

/WX-

关闭“将 warning 当成 error”。


9. build.cmd 成功后的现象

如果 Colosseum 本体编译成功,会看到类似 AirLib 生成并复制到 Unreal 插件目录:

<ColosseumRoot>\Unreal\Plugins\AirSim\Source\AirLib\lib\x64\Debug\AirLib.lib
<ColosseumRoot>\Unreal\Plugins\AirSim\Source\AirLib\lib\x64\Release\AirLib.lib
<ColosseumRoot>\Unreal\Plugins\AirSim\Source\AirLib\lib\x64\RelWithDebInfo\AirLib.lib

脚本中可能会出现:

The system cannot find the file specified.
Could Not Find ...

这通常不是严重错误。很多情况下只是脚本尝试删除旧的 BuildBinariesIntermediateSaved 或旧 .sln 文件,而这些文件原本不存在。


10. 打开 BlocksV2 项目

进入:

<BlocksV2Root>

如果已经生成 .sln 文件,直接打开。

如果没有 .sln,可以右键:

BlocksV2.uproject

选择:

Generate Visual Studio project files

然后打开生成的解决方案。

在 Visual Studio 中选择:

配置:Development Editor
平台:Win64 / x64
启动项目:BlocksV2

可以先执行:

生成 → 重新生成解决方案

或者点击:

Local Windows Debugger

11. UE5.6 兼容性报错

Colosseum 本体 build.cmd 通过后,BlocksV2 在 UE5.6 中编译 AirSim 插件时,可能出现 UE API 兼容性问题。

主要有以下几类:

LineBatcher 不是 UWorld 的成员
PersistentLineBatcher 不是 UWorld 的成员
TObjectPtr<APawn> 无法转换为 APawn*
FLinearColor 无法转换为 FColor

这些问题需要修改 BlocksV2 内部的 AirSim 插件源码。

注意修改的是:

<BlocksAirSimPlugin>\Source\...

而不是只修改:

<ColosseumRoot>\Unreal\Plugins\AirSim

12. 修复 PawnSimApi.cpp

打开:

<BlocksAirSimPlugin>\Source\PawnSimApi.cpp

在 include 区域添加:

#include "DrawDebugHelpers.h"

12.1 原始错误

可能出现:

error C2039: "LineBatcher": 不是 "UWorld" 的成员

原代码类似:

params_.pawn->GetWorld()->LineBatcher->DrawLine(
    params_.pawn->GetActorLocation(),
    target_location,
    color,
    SDPG_World,
    10,
    -1
);

12.2 修改为 DrawDebugLine

将两处类似代码替换为:

DrawDebugLine(
    params_.pawn->GetWorld(),
    params_.pawn->GetActorLocation(),
    target_location,
    color.ToFColor(true),
    false,
    -1.0f,
    SDPG_World,
    10.0f
);

注意这里必须使用:

color.ToFColor(true)

不能直接传:

color

因为 DrawDebugLine 第四个参数需要 FColor,而原变量通常是 FLinearColor


13. 修复 WorldSimApi.cpp

打开:

<BlocksAirSimPlugin>\Source\WorldSimApi.cpp

在 include 区域添加:

#include "DrawDebugHelpers.h"

13.1 原始错误

可能出现:

error C2039: "PersistentLineBatcher": 不是 "UWorld" 的成员

原代码类似:

simmode_->GetWorld()->PersistentLineBatcher->DrawLine(
    point1,
    point2,
    color,
    SDPG_World,
    4,
    999999
);

13.2 修改为 DrawDebugLine

替换为:

DrawDebugLine(
    simmode_->GetWorld(),
    point1,
    point2,
    color.ToFColor(true),
    true,
    999999.0f,
    SDPG_World,
    4.0f
);

14. 修复 SimHUD.cpp

打开:

<BlocksAirSimPlugin>\Source\SimHUD\SimHUD.cpp

14.1 报错现象

可能出现:

error C3535: 无法推导 “auto *” 的类型,依据 “TObjectPtr<APawn>”
error C2440: 无法从 “TObjectPtr<APawn>” 转换为指针
error C2672: “StringCast”: 未找到匹配的重载函数

14.2 修复 pawn 类型

将:

auto* pawn = player_controller->GetPawn();

替换为:

APawn* pawn = player_controller->GetPawn().Get();

14.3 修复字符串转换

将:

std::string pawn_name = std::string(TCHAR_TO_ANSI(*pawn->GetName()));

替换为:

std::string pawn_name(TCHAR_TO_UTF8(*pawn->GetName()));

15. 重新编译 BlocksV2

修改完成并保存后,在 Visual Studio 中执行:

生成 → 重新生成解决方案

或者按:

Ctrl + Shift + B

如果点击 Local Windows Debugger 时弹出:

发生生成错误。是否继续并运行上次的成功生成?

应该点击:

不要运行旧版本。只有编译成功后再运行。


16. 最终编译成功

成功日志通常类似:

[1/6] Compile [x64] PawnSimApi.cpp
[2/6] Compile [x64] WorldSimApi.cpp
[3/6] Link [x64] UnrealEditor-AirSim.lib
[4/6] Link [x64] UnrealEditor-BlocksV2.dll
[5/6] Link [x64] UnrealEditor-AirSim.dll
[6/6] WriteMetadata BlocksV2Editor.target
​
Result: Succeeded
生成: 1 成功,0 失败

这说明:

BlocksV2
AirSim 插件
Colosseum 编译结果

已经可以在 UE5.6 中正常编译。


17. 运行 BlocksV2

编译成功后,在 Visual Studio 中点击:

Local Windows Debugger

等待 Unreal Editor 打开。

进入 Unreal Editor 后点击:

Play

如果场景可以正常运行,则说明 Colosseum / AirSim 插件已经成功在 UE5.6 中运行。


18. 安装本地 PythonClient

为了让 Python 使用当前 Colosseum 自带的 AirSim API,而不是 pip 上可能较旧的 airsim,建议安装本地源码版本。

进入:

cd <ColosseumRoot>\PythonClient

如果之前安装过 pip 版本,可以先卸载:

py -m pip uninstall airsim

安装本地源码版:

py -m pip install -e .

检查导入路径:

py -c "import airsim; print(airsim.__file__)"

如果输出路径指向:

<ColosseumRoot>\PythonClient\airsim\...

说明安装的是 Colosseum 自带 PythonClient。


19. 测试 Python API

保持 UE 中 BlocksV2 正在 Play。

新建测试脚本:

import airsim
​
client = airsim.MultirotorClient()
client.confirmConnection()
​
print("Connected successfully.")
print(client.getMultirotorState())

运行:

py test_airsim.py

如果输出:

Connected successfully.

说明 Python API 可以连接 Colosseum / AirSim。


20. 迁移到其他 UE 项目的注意事项

当前成功修改的是 BlocksV2 内部的插件副本:

<BlocksV2Root>\Plugins\AirSim

如果后续需要迁移到其他 UE 项目,例如自定义场景或 CitySample,需要注意:

不要直接复制未修改过的原始插件。

建议将已经修好的插件复制到目标项目:

<YourUnrealProject>
└── Plugins
    └── AirSim

或者同步以下文件的修改:

Source\PawnSimApi.cpp
Source\WorldSimApi.cpp
Source\SimHUD\SimHUD.cpp

否则目标项目编译时可能再次遇到:

LineBatcher 不是 UWorld 的成员
PersistentLineBatcher 不是 UWorld 的成员
TObjectPtr<APawn> 无法转换为 APawn*
FLinearColor 无法转换为 FColor

21. 常用命令汇总

21.1 Colosseum 编译

cd <ColosseumRoot>
chcp 65001
set CL=/wd4819 /wd4127
set _CL_=/wd4819 /wd4127 /WX-
build.cmd

21.2 更强版本

cd <ColosseumRoot>
chcp 65001
set CL=/utf-8 /wd4819 /wd4127
set _CL_=/utf-8 /wd4819 /wd4127 /WX-
build.cmd

21.3 PythonClient 本地安装

cd <ColosseumRoot>\PythonClient
py -m pip uninstall airsim
py -m pip install -e .
py -c "import airsim; print(airsim.__file__)"

21.4 BlocksV2 编译运行

打开 BlocksV2.sln
配置选择 Development Editor
平台选择 Win64 / x64
生成 → 重新生成解决方案
Local Windows Debugger
UE Editor 打开后点击 Play

22. 问题与解决方案总表

阶段 报错 / 现象 原因 解决方案
build.cmd Colosseum_Eigen not properly initialized Eigen 子模块未下载 手动下载 Eigen 3.4.0 并放到 ExternalRepositories\Colosseum_Eigen\Eigen
git submodule GitHub 443 连接失败 网络无法访问 GitHub 换网络、配置代理,或手动下载依赖
build.cmd C4819 + C2220 编码 warning 被当成 error chcp 65001 + set CL=/wd4819
build.cmd C4127 + C2220 Eigen warning 被当成 error set CL=/wd4819 /wd4127set _CL_=/wd4819 /wd4127 /WX-
BlocksV2 编译 LineBatcher 不是 UWorld 成员 UE5.6 API 兼容问题 改用 DrawDebugLine(...)
BlocksV2 编译 PersistentLineBatcher 不是 UWorld 成员 UE5.6 API 兼容问题 改用 DrawDebugLine(...)
BlocksV2 编译 TObjectPtr<APawn> 无法转换 UE5.6 GetPawn() 返回类型变化 APawn* pawn = player_controller->GetPawn().Get();
BlocksV2 编译 FLinearColor 无法转换为 FColor DrawDebugLine 需要 FColor 使用 color.ToFColor(true)
运行 UE 可以打开并 Play 编译与插件加载成功 继续配置 settings.json 和 Python API

23. 总结

在 Windows + UE5.6 环境中编译 Colosseum / AirSim,主要难点集中在三个方面:

  1. 依赖下载问题:Eigen 子模块可能无法正常下载,可以手动下载 Eigen 3.4.0 解决;

  2. 中文 Windows 编译警告问题C4819C4127 可能被当作错误,需要通过 CL / _CL_ 编译参数关闭;

  3. UE5.6 API 兼容问题:需要将 LineBatcher / PersistentLineBatcher 改为 DrawDebugLine,并处理 TObjectPtr<APawn>FLinearColor 的类型变化。

完成这些修改后,Colosseum 自带的 BlocksV2 项目可以在 UE5.6 中成功编译、打开 Unreal Editor,并点击 Play 正常运行。

Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐