Carla 中的 Chrono 实现
这是一个 UE4 车辆运动组件,用 Chrono 物理引擎(专业多体动力学库)替代 UE4 的 PhysX,提供更精确的车辆动力学、悬挂、轮胎和地形交互模拟。
Chrono 需要在虚幻引擎端启用 RTTI(RTTI(Run-Time Type Information),从而支持动态类型识别和异常处理等功能。
文件 Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Carla.Build.cs 中增加bUseRTTI = true;。
笔记
每个.Build.cs文件声明派生自ModuleRules基类的类,并设置属性控制器从构造函数进行编译的方式。由虚幻编译工具编译,并被构造来确定整体编译环境。使用C#语法。
流程
-
初始化阶段 (CreateChronoMovementComponent + BeginPlay )
1.1 创建组件并配置 JSON 参数(车辆、动力总成、轮胎配置)
1.2 BeginPlay:初始化 Chrono 系统 : 设置重力、求解器(Barzilai -Borwein 方法是一种迭代梯度下降法)、迭代次数
-
Carla -> Chrono:每帧更新 ( TickComponent )
2.1 时间子步处理:
如果单帧时间 > MaxSubstepDeltaTime(默认 0.01s),分解为多个小步进行精确计算。否则直接用该帧时间步
2.2 物理仿真:AdvanceChronoSimulation(StepSize) :同步时间、控制(转向、油门、刹车)、地形 到 chrono
-
Chrono -> Carla:位置/旋转同步回 UE4 :
坐标系转换:Chrono(右手系,米)↔ UE4(左手系,厘米)
地形交互 (UERayCastTerrain):Chrono 需要知道地形 高度 、法线 、摩擦系数 来计算轮胎力。本实现通过光线投射到 UE4
提交历史
- Support custom chrono (#9182)
- lower COM Z-height to 0.52 m for realistic sedan dynamics (#9126)
- Removed harcoded path for chrono(#9100)
- generate all supported PythonAPI installation file (#3260)
- fix "carla\Unreal\CarlaUE4\Plugins\Carla\CarlaDependencies\dll\ChronoEngine.dll" missing caused by chrono source code download failed
- 兼容VS2019和VS2022 (#3227)
- Added restore_physx_physics function
- Add build support for VS2022 and Ninja for LibCarla and osm2odr on Windows
- Make (Unreal) non-unity build available (#6190)
- Changed rotation and position offsets for chrono. Disabled overlap events for some meshes
- Changed Custom movement component begin play execution order to prevent disable before initialization
- Adding new attachment type 'SpringArmGhost'
- Luis/collisions bushes (#5477)
- Fixed issues with new map.name
- Re-Upload : Enabled overlap events on static meshes for chrono-carsim
- Setup Visual Studio 2019 for windows
- Fix minor typo
- Large Maps (#4207)
- Corkyw10/chrono docs (#4160) - chrono 文档
- Disable chrono upon collision - 当碰撞时候禁用 chrono
- Added collision detection for chrono vehicles. - 给启用 chrono 的载具添加碰撞检测器
- Added trace profiler events for unreal insights.
- Fixed chrono Dlls separated from the binary file
- Removed tabs.
- Added missing chrono macros
- Fixed std issues in chrono implementation in windows.
- Enabling exceptions for chrono package.
- Overloaded all UBaseCarlaMovementComponent functions in UChronoMovementComponent
- Added JSON ingestion for chrono vehicle definition
- Review fixes.
- Set chrono version to 6.0.0.
- Skipping 0 delta times.
- Small fix for Windows compilation without chrono.
- Fixed fall through bug for chrono vehicle.
- Small fix to windows build
- Added missing .lib from chrono to Build.cs
- Updated chrono install for windows.
- Added release compile mode for chrono library.
- Added substep algorithm for chrono. Added initial UE4 terrain detection with raycast.
- Added chrono compilation support for windows.
- Created base chrono implementation
- Added chrono library