CARLA
 
载入中...
搜索中...
未找到
LibCarla/source/carla/rpc/EpisodeSettings.h
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include "carla/MsgPack.h"
11
12#ifdef LIBCARLA_INCLUDED_FROM_UE4
16#endif // LIBCARLA_INCLUDED_FROM_UE4
17
18#include <boost/optional.hpp>
19
20namespace carla {
21namespace rpc {
22
24 public:
25 // =========================================================================
26 // -- 公开的数据成员 --------------------------------------------------------
27 // =========================================================================
28
29 // 是否启用同步模式
30 bool synchronous_mode = false;
31
32 // 是否启用无渲染模式
33 bool no_rendering_mode = false;
34
35 // 可选的固定时间间隔,使用 boost::optional 来表示该值可能存在也可能不存在
36 boost::optional<double> fixed_delta_seconds;
37
38 // 是否启用子步,默认为 true
39 bool substepping = true;
40
41 // 两个物理子步之间的最大时间
42 double max_substep_delta_time = 0.01;
43
44 // 一个仿真帧包含的最多物理子步数
45 int max_substeps = 10;
46
47 // 距离剔除:当对象尺寸足够小,距离镜头足够远时,可以不进行渲染,以提高性能
48 // https://www.jianshu.com/p/537d297bedfa
50
51 // 确定性布娃娃系统,默认为 true
53
54 // 该关卡中 距离玩家 3km 内的地图瓦片会被加载
55 float tile_stream_distance = 3000.f; // 3km
56
57 // 距离玩家 2km 内的参与者会被激活
58 float actor_active_distance = 2000.f; // 2km
59
60 // 是否将观众视为自我,默认为 true
61 bool spectator_as_ego = true;
62
63 // 使用 MSGPACK_DEFINE_ARRAY 宏将类的成员变量按顺序打包到 msgpack 中,用于序列化
67
68 // =========================================================================
69 // -- 构造函数 --------------------------------------------------------------
70 // =========================================================================
71
72 // 默认构造函数,使用编译器生成的默认实现
73 EpisodeSettings() = default;
74
75 // 带有参数的构造函数,可以指定各项设置
100
101 // =========================================================================
102 // -- 比较操作符 ------------------------------------------------------------
103 // =========================================================================
104
105 // 重载 == 操作符,用于比较两个 EpisodeSettings 对象是否相等
120
121 // 重载!= 操作符,使用 == 操作符的结果取反
122 bool operator!=(const EpisodeSettings &rhs) const {
123 return!(*this == rhs);
124 }
125
126 // =========================================================================
127 // -- 转换成虚幻4类型 -------------------------------------------------------
128 // =========================================================================
129
130#ifdef LIBCARLA_INCLUDED_FROM_UE4
131 // 从虚幻4的 FEpisodeSettings 类型构造 EpisodeSettings
134 Settings.bSynchronousMode,
135 Settings.bNoRenderingMode,
136 Settings.FixedDeltaSeconds.Get(0.0),
137 Settings.bSubstepping,
138 Settings.MaxSubstepDeltaTime,
139 Settings.MaxSubsteps,
140 Settings.MaxCullingDistance,
141 Settings.bDeterministicRagdolls,
142 Settings.TileStreamingDistance,
143 Settings.ActorActiveDistance,
144 Settings.SpectatorAsEgo) {
145 constexpr float CMTOM = 1.f/100.f;
148 }
149
150 // 类型转换运算符,将 EpisodeSettings 转换为虚幻4的 FEpisodeSettings 类型
151 operator FEpisodeSettings() const {
152 constexpr float MTOCM = 100.f;
153 FEpisodeSettings Settings;
156 if (fixed_delta_seconds.has_value()) {
158 }
159 Settings.bSubstepping = substepping;
161 Settings.MaxSubsteps = max_substeps;
167
168 return Settings;
169 }
170#endif // LIBCARLA_INCLUDED_FROM_UE4
171 };
172
173} // namespace rpc
174} // namespace carla
bool operator==(const EpisodeSettings &rhs) const
MSGPACK_DEFINE_ARRAY(synchronous_mode, no_rendering_mode, fixed_delta_seconds, substepping, max_substep_delta_time, max_substeps, max_culling_distance, deterministic_ragdolls, tile_stream_distance, actor_active_distance, spectator_as_ego)
EpisodeSettings(bool synchronous_mode, bool no_rendering_mode, double fixed_delta_seconds=0.0, bool substepping=true, double max_substep_delta_time=0.01, int max_substeps=10, float max_culling_distance=0.0f, bool deterministic_ragdolls=true, float tile_stream_distance=3000.f, float actor_active_distance=2000.f, bool spectator_as_ego=true)
bool operator!=(const EpisodeSettings &rhs) const
CARLA模拟器的主命名空间。
Definition Carla.cpp:139