CARLA
 
载入中...
搜索中...
未找到
CachedSimpleWaypoint.h
浏览该文件的文档.
1// Copyright (c) 2021 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 <fstream>
10
12
13namespace carla { // 命名空间 carla 开始
14namespace traffic_manager { // 命名空间 traffic_manager 开始
15
16 using SimpleWaypointPtr = std::shared_ptr<SimpleWaypoint>; // 定义类型别名 SimpleWaypointPtr 为 std::shared_ptr<SimpleWaypoint>
17
18 class CachedSimpleWaypoint { // 定义类 CachedSimpleWaypoint
19 public:
20 uint64_t waypoint_id; // 存储路点的唯一标识 ID
21 uint32_t road_id; // 存储路点所在道路的 ID
22 uint32_t section_id; // 存储路点所在路段的 ID
23 int32_t lane_id; // 存储路点在车道上的位置参数 s
24 float s; // 位置参数 s 的类型为浮点数
25 std::vector<uint64_t> next_waypoints; // 存储当前路点的下一个路点的 ID 列表
26 std::vector<uint64_t> previous_waypoints; // 存储当前路点的前一个路点的 ID 列表
27 uint64_t next_left_waypoint = 0; // 存储当前路点左侧下一个路点的 ID,初始值为 0
28 uint64_t next_right_waypoint = 0; // 存储当前路点右侧下一个路点的 ID,初始值为 0
29 int32_t geodesic_grid_id; // 存储与测地线网格相关的 ID
30 bool is_junction; // 表示路点是否在路口的布尔值
31 uint8_t road_option; // 道路选项,可能用于表示路点的特定属性
32
33 CachedSimpleWaypoint() = default; // 默认构造函数
34
35 CachedSimpleWaypoint(const SimpleWaypointPtr& simple_waypoint); // 带参数的构造函数,参数为 SimpleWaypoint 的智能指针
36
37 void Read(const std::vector<uint8_t>& content, unsigned long& start); // 从字节向量中读取路点信息的函数,传入字节向量和起始位置引用
38
39 void Read(std::ifstream &in_file); // 从输入文件流中读取路点信息的函数
40
41 void Write(std::ofstream &out_file); // 将路点信息写入输出文件流的函数
42
43 private:
44 template <typename T>
45 void WriteValue(std::ofstream &out_file, const T &in_obj) {
46 out_file.write(reinterpret_cast<const char *>(&in_obj), sizeof(T));
47 }
48 // 模板函数,将输入对象写入输出文件流,用于将不同类型的数据写入文件
49
50 template <typename T>
51 void ReadValue(std::ifstream &in_file, T &out_obj) {
52 in_file.read(reinterpret_cast<char *>(&out_obj), sizeof(T));
53 }
54 // 模板函数,从输入文件流中读取数据并存储到输出对象中,用于从文件中读取不同类型的数据
55
56 template <typename T>
57 void ReadValue(const std::vector<uint8_t>& content, unsigned long& start, T &out_obj) {
58 memcpy(&out_obj, &content[start], sizeof(T));
59 start += sizeof(T);
60 }
61 // 模板函数,从字节向量中读取数据并存储到输出对象中,同时更新起始位置,用于从字节向量中读取不同类型的数据
62
63 };
64
65} // namespace traffic_manager // 命名空间 traffic_manager 结束
66} // namespace carla // 命名空间 carla 结束
void ReadValue(std::ifstream &in_file, T &out_obj)
void ReadValue(const std::vector< uint8_t > &content, unsigned long &start, T &out_obj)
void Read(const std::vector< uint8_t > &content, unsigned long &start)
void Write(std::ofstream &out_file)
void WriteValue(std::ofstream &out_file, const T &in_obj)
CachedSimpleWaypoint(const SimpleWaypointPtr &simple_waypoint)
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
CARLA模拟器的主命名空间。
Definition Carla.cpp:139