CARLA
 
载入中...
搜索中...
未找到
client/Map.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/// @cond DoxygenSuppress
9
10// 包含CARLA内存管理相关的头文件
11#include "carla/Memory.h"
12// 包含CARLA不可复制类的头文件,用于防止对象被复制
13#include "carla/NonCopyable.h"
14// 包含CARLA道路元素中的车道标记(LaneMarking)的头文件
16// 包含CARLA道路(Lane)的头文件
17#include "carla/road/Lane.h"
18// 包含CARLA地图(Map)的头文件
19#include "carla/road/Map.h"
20// 包含CARLA道路类型(RoadTypes)的头文件
22// 包含CARLA RPC地图信息(MapInfo)的头文件
23#include "carla/rpc/MapInfo.h"
24// 包含地标(Landmark)的头文件
25#include "Landmark.h"
26
27#include <string>
28/**
29 * @namespace carla::client
30 * @brief CARLA仿真框架中的客户端命名空间,包含与地图交互的类。
31 */
32namespace carla {
33namespace geom {
34 /**
35 * @class GeoLocation
36 * @brief 定义几何位置类,用于表示地图上的地理位置。
37 */class GeoLocation; }
38namespace client {
39 /**
40 * @class Waypoint
41 * @brief 声明路点类,表示地图上的一个具体点,通常与道路网络中的某个位置相关联。
42 */
43 class Waypoint;
44 /**
45 * @class Junction
46 * @brief 声明交叉口类,表示地图上的一个交叉口或道路交汇点。
47 */
48 class Junction;
49 /**
50 * @class Map
51 * @brief 地图类,用于表示和操作CARLA仿真中的地图。
52 *
53 * 该类提供了丰富的接口来查询地图信息、处理路点和地标、以及获取地图的拓扑结构等。
54 * 它继承自EnableSharedFromThis以支持智能指针的共享,并私有继承了NonCopyable以防止对象被复制。
55 */
56 class Map
57 : public EnableSharedFromThis<Map>,
58 private NonCopyable {
59 public:
60 /**
61 * @brief 构造函数,从RPC地图信息和OpenDRIVE内容创建地图。
62 *
63 * @param description 描述地图信息的RPC对象。
64 * @param xodr_content 包含OpenDRIVE地图数据的字符串。
65 */
66 explicit Map(rpc::MapInfo description, std::string xodr_content);
67 /**
68 * @brief 构造函数,从名称和OpenDRIVE内容创建地图。
69 *
70 * @param name 地图的名称。
71 * @param xodr_content 包含OpenDRIVE地图数据的字符串。
72 */
73 explicit Map(std::string name, std::string xodr_content);
74 /**
75 * @brief 析构函数。
76 */
77 ~Map();
78 /**
79 * @brief 获取地图名称。
80 *
81 * @return 返回地图名称的常量引用。
82 */
83 const std::string &GetName() const {
84 return _description.name;
85 }
86 /**
87 * @brief 获取道路地图。
88 *
89 * @return 返回道路地图的常量引用。
90 */
91 const road::Map &GetMap() const {
92 return _map;
93 }
94 /**
95 * @brief 获取OpenDRIVE文件内容。
96 *
97 * @return 返回包含OpenDRIVE文件内容的字符串的常量引用。
98 */
99 const std::string &GetOpenDrive() const {
100 return open_drive_file;
101 }
102 /**
103 * @brief 获取推荐生成点。
104 *
105 * @return 返回推荐生成点(`geom::Transform`对象的向量)的常量引用。
106 */
107 const std::vector<geom::Transform> &GetRecommendedSpawnPoints() const {
108 return _description.recommended_spawn_points;
109 }
110 /**
111 * @brief 获取路点,可以选择是否投影到道路上。
112 *
113 * @param location 地理位置。
114 * @param project_to_road 是否将位置投影到最近的道路上(默认为true)。
115 * @param lane_type 车道类型(默认为驾驶车道)。
116 * @return 返回指向路点对象的智能指针。
117 */
118 SharedPtr<Waypoint> GetWaypoint(
119 const geom::Location &location,
120 bool project_to_road = true,
121 int32_t lane_type = static_cast<uint32_t>(road::Lane::LaneType::Driving)) const;
122 /**
123 * @brief 根据OpenDRIVE ID获取路点。
124 *
125 * @param road_id 道路ID。
126 * @param lane_id 车道ID。
127 * @param s 沿车道的距离。
128 * @return 返回指向路点对象的智能指针。
129 */
130 SharedPtr<Waypoint> GetWaypointXODR(
131 carla::road::RoadId road_id,
132 carla::road::LaneId lane_id,
133 float s) const;
134 /**
135 * @brief 拓扑结构列表的类型定义。
136 */
137 using TopologyList = std::vector<std::pair<SharedPtr<Waypoint>, SharedPtr<Waypoint>>>;
138 /**
139 * @brief 获取地图的拓扑结构。
140 *
141 * @return 返回拓扑结构列表。
142 */
143 TopologyList GetTopology() const;
144 /**
145 * @brief 根据距离生成路点。
146 *
147 * @param distance 距离。
148 * @return 返回生成的路点(智能指针的向量)。
149 */
150 std::vector<SharedPtr<Waypoint>> GenerateWaypoints(double distance) const;
151 /**
152 * @brief 计算从起点到终点所跨越的车道。
153 *
154 * @param origin 起点位置。
155 * @param destination 终点位置。
156 * @return 返回跨越的车道标记的向量。
157 */
158 std::vector<road::element::LaneMarking> CalculateCrossedLanes(
159 const geom::Location &origin,
160 const geom::Location &destination) const;
161 /**
162 * @brief 获取地理参考。
163 *
164 * @return 返回地理参考的常量引用。
165 */
166 const geom::GeoLocation &GetGeoReference() const;
167 /**
168 * @brief 获取所有斑马线区域。
169 *
170 * @return 返回斑马线区域位置(`geom::Location`对象的向量)的常量引用。
171 */
172 std::vector<geom::Location> GetAllCrosswalkZones() const;
173 /**
174 * @brief 获取指定路点所属的路口对象。
175 *
176 * @param waypoint 路点对象。
177 * @return 返回指向路口对象的智能指针。
178 */
179 SharedPtr<Junction> GetJunction(const Waypoint &waypoint) const;
180
181 /**
182 * @brief 返回路口中每条车道的起始和结束路点。
183 *
184 * @param id 路口ID。
185 * @param type 车道类型。
186 * @return 返回路口车道路点的对(智能指针)的向量。
187 */
188 std::vector<std::pair<SharedPtr<Waypoint>, SharedPtr<Waypoint>>> GetJunctionWaypoints(
189 road::JuncId id, road::Lane::LaneType type) const;
190
191 /**
192 * @brief 获取地图中所有的地标。
193 *
194 * @return 返回所有地标(智能指针的向量)。
195 */
196 std::vector<SharedPtr<Landmark>> GetAllLandmarks() const;
197
198 /**
199 * @brief 根据特定的OpenDRIVE ID获取地图中的所有地标。
200 *
201 * @param id OpenDRIVE ID。
202 * @return 返回与ID匹配的地标(智能指针的向量)。
203 */
204 std::vector<SharedPtr<Landmark>> GetLandmarksFromId(std::string id) const;
205
206 /**
207 * @brief 根据特定类型获取地图中的所有地标。
208 *
209 * @param type 地标类型。
210 * @return 返回与类型匹配的地标(智能指针的向量)。
211 */
212 std::vector<SharedPtr<Landmark>> GetAllLandmarksOfType(std::string type) const;
213
214 /**
215 * @brief 获取与指定地标在同一组的所有地标。
216 *
217 * @param landmark 指定地标对象。
218 * @return 返回与指定地标在同一组的地标(智能指针的向量)。
219 */
220 std::vector<SharedPtr<Landmark>> GetLandmarkGroup(const Landmark &landmark) const;
221
222 /**
223 * @brief 制作交通管理器使用的内存地图。
224 *
225 * @param path 地图存储路径。
226 */
227 void CookInMemoryMap(const std::string& path) const;
228
229 private:
230
231 std::string open_drive_file;// 包含OpenDRIVE文件内容的字符串
232
233 const rpc::MapInfo _description; // 描述地图信息的RPC对象
234
235 const road::Map _map; // 道路地图的内部表示
236 };
237
238} // namespace client
239} // namespace carla
地图类的前向声明,用于在LaneInvasionSensor类中可能的引用。
int32_t LaneId
Definition RoadTypes.h:26
uint32_t RoadId
Definition RoadTypes.h:20
carla::SharedPtr< carla::client::Junction > Junction
std::vector< std::pair< WaypointPtr, WaypointPtr > > TopologyList
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
包含CARLA客户端相关类和函数的命名空间。