CARLA
 
载入中...
搜索中...
未找到
EpisodeState.cpp
浏览该文件的文档.
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// 引入必要的头文件
8
9namespace carla {
10namespace client {
11namespace detail {
12
13// EpisodeState类的构造函数,用于初始化一个EpisodeState对象
14 // 参数:state - 一个const引用,指向sensor::data::RawEpisodeState类型的数据,包含了当前模拟场景的状态信息
16 // 使用传入的RawEpisodeState对象中的数据来初始化EpisodeState对象的成员变量
17 : _episode_id(state.GetEpisodeId()),// 初始化_episode_id,表示当前模拟场景的ID
18 _timestamp(// 初始化_timestamp,包含帧信息、游戏时间戳、时间差、平台时间戳
19 state.GetFrame(),
20 state.GetGameTimeStamp(),
21 state.GetDeltaSeconds(),
22 state.GetPlatformTimeStamp()),
23 _map_origin(state.GetMapOrigin()),// 初始化_map_origin,表示地图的原点
24 _simulation_state(state.GetSimulationState()) {// 初始化_simulation_state,表示当前的模拟状态
25 // 预留空间以存储所有的Actor快照
26 _actors.reserve(state.size());
27// 遍历RawEpisodeState中的所有Actor,并为每个Actor创建一个ActorSnapshot对象
28 for (auto &&actor : state) {
29 // 使用emplace方法将ActorSnapshot对象插入到_actors映射中
30 // 键是Actor的ID,值是ActorSnapshot对象
31 // DEBUG_ONLY(auto result = ) 这部分代码用于调试,用于检查插入操作是否成功
32 DEBUG_ONLY(auto result = )
33 _actors.emplace(
34 actor.id,
35 ActorSnapshot{// 初始化ActorSnapshot对象
36 actor.id, // Actor的ID
37 actor.actor_state, // Actor的状态
38 actor.transform,// Actor的变换(位置和方向)
39 actor.velocity,// Actor的速度
40 actor.angular_velocity,// Actor的角速度
41 actor.acceleration,// Actor的加速度
42 actor.state});// Actor的附加状态信息
43 DEBUG_ASSERT(result.second);
44 // DEBUG_ASSERT(result.second); 这部分代码用于调试,确保emplace操作成功,即没有重复键
45 }
46 }
47
48} // namespace detail
49} // namespace client
50} // namespace carla
#define DEBUG_ASSERT(predicate)
Definition Debug.h:68
#define DEBUG_ONLY(code)
Definition Debug.h:55
EpisodeState(uint64_t episode_id)
std::unordered_map< ActorId, ActorSnapshot > _actors
size_type size() const
Definition Array.h:103
表示给定帧处剧集的状态。
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
包含CARLA客户端相关类和函数的命名空间。