CARLA
 
载入中...
搜索中...
未找到
EpisodeStateSerializer.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/Buffer.h" // 包含用于处理缓冲区数据的相关定义
10#include "carla/Debug.h" // 包含调试相关的宏和工具
11#include "carla/Memory.h" // 包含智能指针和内存管理工具
12#include "carla/geom/Transform.h" // 包含几何变换工具,例如位姿和旋转
13#include "carla/geom/Vector3DInt.h" // 包含整数三维向量定义
14#include "carla/sensor/RawData.h"// 包含传感器原始数据的相关定义
15#include "carla/sensor/data/ActorDynamicState.h" // 包含动态对象状态的定义
16
17#include <cstdint>// 标准库,用于固定宽度的整数类型
18
19namespace carla {
20namespace sensor {
21
22 class SensorData;//传感器数据的基类声明
23
24namespace s11n {
25
26 /// Serializes the current state of the whole episode.
28 public:
29
30 enum SimulationState { //枚举类,用于表示模拟状态的类型
31 None = (0x0 << 0), // 默认状态,无特定更新
32 MapChange = (0x1 << 0), // 表示地图变更的状态
33 PendingLightUpdate = (0x1 << 1) // 表示待处理的交通信号灯更新
34 };
35
36#pragma pack(push, 1)
37 struct Header { // 数据包的头部结构,用于描述序列化数据的元信息
38 uint64_t episode_id; // 会话唯一标识符
39 double platform_timestamp; // 时间戳,表示当前平台的时间
40 float delta_seconds; // 当前状态与上一状态之间的时间差
41 geom::Vector3DInt map_origin; // 地图的原点位置(三维整数坐标)
43 };
44#pragma pack(pop)
45
46 constexpr static auto header_offset = sizeof(Header); // 数据头部的偏移量,用于快速定位数据正文
47
48 //反序列化数据包头部
49 static const Header &DeserializeHeader(const RawData &message) { // 反序列化数据包头部
50 return *reinterpret_cast<const Header *>(message.begin()); // 返回解析后的'Header'结构体的引用
51 }
52
53 template <typename SensorT>//序列化传感器数据
54 static Buffer Serialize(const SensorT &, Buffer &&buffer) { // Sensor为输入的传感器对像,buffer为输入的缓冲区数据
55 return std::move(buffer); // 直接返回传入的缓冲区数据
56 }
57
58 static SharedPtr<SensorData> Deserialize(RawData &&data); //data输入的原始数据
59 }; // 返回反序列化后的传感器数据对象的智能指针
60
61} // namespace s11n
62} // namespace sensor
63} // namespace carla
一块原始数据。 请注意,如果需要更多容量,则会分配一个新的内存块,并 删除旧的内存块。这意味着默认情况下,缓冲区只能增长。要释放内存,使用 clear 或 pop。
包装一个传感器生成的原始数据以及一些有用的元信息。
Definition RawData.h:20
auto begin() noexcept
指向传感器生成的数据的开始迭代器。
Definition RawData.h:52
Serializes the current state of the whole episode.
static Buffer Serialize(const SensorT &, Buffer &&buffer)
static const Header & DeserializeHeader(const RawData &message)
static SharedPtr< SensorData > Deserialize(RawData &&data)
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
boost::shared_ptr< T > SharedPtr
使用这个SharedPtr(boost::shared_ptr)以保持与boost::python的兼容性, 但未来如果可能的话,我们希望能为std::shared_ptr制作一个Python适配器。
Definition Memory.h:19