CARLA
 
载入中...
搜索中...
未找到
MapBuilder.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/road/Map.h" // 引入地图模块
10#include "carla/road/element/RoadInfoCrosswalk.h" // 引入人行横道信息模块
11#include "carla/road/element/RoadInfoSignal.h" // 引入交通信号信息模块
12
13#include <boost/optional.hpp> // 引入可选类型模块
14
15#include <map> // 引入映射容器模块
16
17namespace carla {
18namespace road {
19
20 class MapBuilder {
21 public:
22
23 boost::optional<Map> Build(); // 构建地图并返回一个可选的地图对象
24
25 // 从道路解析器调用
27 const RoadId road_id, // 道路ID
28 const std::string name, // 道路名称
29 const double length, // 道路长度
30 const JuncId junction_id, // 交叉口ID
31 const RoadId predecessor, // 前驱道路ID
32 const RoadId successor); // 后继道路ID
33
35 carla::road::Road *road, // 指向道路的指针
36 const SectionId id, // 道路段ID
37 const double s); // 位置参数
38
40 carla::road::LaneSection *section, // 道路段指针
41 const LaneId lane_id, // 车道ID
42 const uint32_t lane_type, // 车道类型
43 const bool lane_level, // 是否平坦
44 const LaneId predecessor, // 前驱车道ID
45 const LaneId successor); // 后继车道ID
46
47 // 从几何解析器调用
49 carla::road::Road *road, // 指向道路的指针
50 const double s, // 位置参数
51 const double x, // x坐标
52 const double y, // y坐标
53 const double hdg, // 航向角
54 const double length); // 线段长度
55
57 carla::road::Road *road, // 指向道路的指针
58 const double s, // 位置参数
59 const double x, // x坐标
60 const double y, // y坐标
61 const double hdg, // 航向角
62 const double length, // 弧长
63 const double curvature); // 曲率
64
66 carla::road::Road *road, // 指向道路的指针
67 const double s, // 位置参数
68 const double x, // x坐标
69 const double y, // y坐标
70 const double hdg, // 航向角
71 const double length, // 螺旋长度
72 const double curvStart, // 起始曲率
73 const double curvEnd); // 结束曲率
74
76 carla::road::Road *road, // 指向道路的指针
77 const double s, // 位置参数
78 const double x, // x坐标
79 const double y, // y坐标
80 const double hdg, // 航向角
81 const double length, // 多项式长度
82 const double a, // 多项式系数a
83 const double b, // 多项式系数b
84 const double c, // 多项式系数c
85 const double d); // 多项式系数d
86
88 carla::road::Road *road, // 指向道路的指针
89 const double s, // 位置参数
90 const double x, // x坐标
91 const double y, // y坐标
92 const double hdg, // 航向角
93 const double length, // 多项式长度
94 const double aU, // 多项式系数a (U方向)
95 const double bU, // 多项式系数b (U方向)
96 const double cU, // 多项式系数c (U方向)
97 const double dU, // 多项式系数d (U方向)
98 const double aV, // 多项式系数a (V方向)
99 const double bV, // 多项式系数b (V方向)
100 const double cV, // 多项式系数c (V方向)
101 const double dV, // 多项式系数d (V方向)
102 const std::string p_range); // 参数范围字符串
103
104 // 从轮廓解析器调用
106 Road *road, // 指向道路的指针
107 const double s, // 位置参数
108 const double a, // 高程参数a
109 const double b, // 高程参数b
110 const double c, // 高程参数c
111 const double d); // 高程参数d
112
114 Road *road, // 指向道路的指针
115 const std::string name, // 人行横道名称
116 const double s, // 位置参数
117 const double t, // 横向位置
118 const double zOffset, // 垂直偏移
119 const double hdg, // 航向角
120 const double pitch, // 倾斜角
121 const double roll, // 翻滚角
122 const std::string orientation, // 定位方向
123 const double width, // 宽度
124 const double length, // 长度
125 const std::vector<road::element::CrosswalkPoint> points); // 人行横道点集
126
127 // void AddRoadLateralSuperElevation(
128 // Road* road,
129 // const double s,
130 // const double a,
131 // const double b,
132 // const double c,
133 // const double d);
134
135 // void AddRoadLateralCrossfall(
136 // Road* road,
137 // const double s,
138 // const double a,
139 // const double b,
140 // const double c,
141 // const double d,
142 // const std::string side);
143
144 // void AddRoadLateralShape(
145 // Road* road,
146 // const double s,
147 // const double a,
148 // const double b,
149 // const double c,
150 // const double d,
151 // const double t);
152
153 // 信号方法
154 element::RoadInfoSignal* AddSignal( // 添加信号的函数
155 Road* road, // 道路指针
156 const SignId signal_id, // 信号标识符
157 const double s, // 在道路上的位置(s坐标)
158 const double t, // 在道路上的横向位置(t坐标)
159 const std::string name, // 信号名称
160 const std::string dynamic, // 动态属性
161 const std::string orientation, // 方向
162 const double zOffset, // Z轴偏移
163 const std::string country, // 国家
164 const std::string type, // 信号类型
165 const std::string subtype, // 信号子类型
166 const double value, // 信号值
167 const std::string unit, // 单位
168 const double height, // 高度
169 const double width, // 宽度
170 const std::string text, // 显示文本
171 const double hOffset, // 水平偏移
172 const double pitch, // 倾斜角度
173 const double roll); // 翻滚角度
174
175void AddSignalPositionInertial( // 添加惯性信号位置的函数
176 const SignId signal_id, // 信号标识符
177 const double x, // X坐标
178 const double y, // Y坐标
179 const double z, // Z坐标
180 const double hdg, // 航向角
181 const double pitch, // 倾斜角度
182 const double roll); // 翻滚角度
183
184void AddSignalPositionRoad( // 添加道路信号位置的函数
185 const SignId signal_id, // 信号标识符
186 const RoadId road_id, // 道路标识符
187 const double s, // 在道路上的位置(s坐标)
188 const double t, // 在道路上的横向位置(t坐标)
189 const double zOffset, // Z轴偏移
190 const double hOffset, // 水平偏移
191 const double pitch, // 倾斜角度
192 const double roll); // 翻滚角度
193
194element::RoadInfoSignal* AddSignalReference( // 添加信号参考的函数
195 Road* road, // 道路指针
196 const SignId signal_id, // 信号标识符
197 const double s_position, // 信号参考位置(s坐标)
198 const double t_position, // 信号参考位置(t坐标)
199 const std::string signal_reference_orientation); // 信号参考方向
200
201void AddValidityToSignalReference( // 向信号参考添加有效性的函数
202 element::RoadInfoSignal* signal_reference, // 信号参考指针
203 const LaneId from_lane, // 起始车道标识符
204 const LaneId to_lane); // 结束车道标识符
205
206void AddDependencyToSignal( // 向信号添加依赖关系的函数
207 const SignId signal_id, // 信号标识符
208 const std::string dependency_id, // 依赖标识符
209 const std::string dependency_type); // 依赖类型
210
211// 从交叉口解析器调用
212void AddJunction( // 添加交叉口的函数
213 const JuncId id, // 交叉口标识符
214 const std::string name); // 交叉口名称
215
216void AddConnection( // 添加连接的函数
217 const JuncId junction_id, // 交叉口标识符
218 const ConId connection_id, // 连接标识符
219 const RoadId incoming_road, // 进入道路标识符
220 const RoadId connecting_road); // 连接道路标识符
221
222void AddLaneLink( // 添加车道链接的函数
223 const JuncId junction_id, // 交叉口标识符
224 const ConId connection_id, // 连接标识符
225 const LaneId from, // 起始车道标识符
226 const LaneId to); // 目标车道标识符
227
228void AddJunctionController( // 添加交叉口控制器的函数
229 const JuncId junction_id, // 交叉口标识符
230 std::set<ContId>&& controllers); // 控制器集合
231
232void AddRoadSection( // 添加道路段的函数
233 const RoadId road_id, // 道路标识符
234 const SectionId section_index, // 道路段索引
235 const double s, // 在道路段上的位置(s坐标)
236 const double a, // 参数a
237 const double b, // 参数b
238 const double c, // 参数c
239 const double d); // 参数d
240
241void SetRoadLaneLink( // 设置道路车道链接的函数
242 const RoadId road_id, // 道路标识符
243 const SectionId section_index, // 道路段索引
244 const LaneId lane_id, // 车道标识符
245 const Lane::LaneType lane_type, // 车道类型
246 const bool lane_level, // 是否为车道级别
247 const LaneId predecessor, // 前驱车道标识符
248 const LaneId successor); // 后继车道标识符
249
250// 从车道解析器调用
251 void CreateLaneAccess( // 创建车道通行权限
252 Lane *lane, // 车道指针
253 const double s, // 在车道上的位置(s坐标)
254 const std::string restriction); // 限制类型
255
256void CreateLaneBorder( // 创建车道边界
257 Lane *lane, // 车道指针
258 const double s, // 在车道上的位置(s坐标)
259 const double a, // 参数a
260 const double b, // 参数b
261 const double c, // 参数c
262 const double d); // 参数d
263
264void CreateLaneHeight( // 创建车道高度
265 Lane *lane, // 车道指针
266 const double s, // 在车道上的位置(s坐标)
267 const double inner, // 内部高度
268 const double outer); // 外部高度
269
270void CreateLaneMaterial( // 创建车道材料属性
271 Lane *lane, // 车道指针
272 const double s, // 在车道上的位置(s坐标)
273 const std::string surface, // 表面类型
274 const double friction, // 摩擦系数
275 const double roughness); // 粗糙度
276
277void CreateSectionOffset( // 创建道路段偏移
278 Road *road, // 道路指针
279 const double s, // 在道路段上的位置(s坐标)
280 const double a, // 参数a
281 const double b, // 参数b
282 const double c, // 参数c
283 const double d); // 参数d
284
285void CreateLaneRule( // 创建车道规则
286 Lane *lane, // 车道指针
287 const double s, // 在车道上的位置(s坐标)
288 const std::string value); // 规则值
289
290void CreateLaneVisibility( // 创建车道可见性
291 Lane *lane, // 车道指针
292 const double s, // 在车道上的位置(s坐标)
293 const double forward, // 前方可见距离
294 const double back, // 后方可见距离
295 const double left, // 左侧可见距离
296 const double right); // 右侧可见距离
297
298void CreateLaneWidth( // 创建车道宽度
299 Lane *lane, // 车道指针
300 const double s, // 在车道上的位置(s坐标)
301 const double a, // 参数a
302 const double b, // 参数b
303 const double c, // 参数c
304 const double d); // 参数d
305
306void CreateRoadMark( // 创建道路标记
307 Lane *lane, // 车道指针
308 const int road_mark_id, // 道路标记标识符
309 const double s, // 在车道上的位置(s坐标)
310 const std::string type, // 标记类型
311 const std::string weight, // 标记重量
312 const std::string color, // 标记颜色
313 const std::string material, // 标记材料
314 const double width, // 标记宽度
315 const std::string lane_change, // 车道变更信息
316 const double height, // 标记高度
317 const std::string type_name, // 标记类型名称
318 const double type_width); // 标记类型宽度
319
320void CreateRoadMarkTypeLine( // 创建道路标记类型线
321 Lane *lane, // 车道指针
322 const int road_mark_id, // 道路标记标识符
323 const double length, // 线段长度
324 const double space, // 线段间距
325 const double tOffset, // 偏移量
326 const double s, // 在车道上的位置(s坐标)
327 const std::string rule, // 规则
328 const double width); // 线宽
329
330void CreateRoadSpeed( // 创建道路速度限制
331 Road *road, // 道路指针
332 const double s, // 在道路上的位置(s坐标)
333 const std::string type, // 限速类型
334 const double max, // 最大速度
335 const std::string unit); // 单位
336
337void CreateLaneSpeed( // 创建车道速度限制
338 Lane *lane, // 车道指针
339 const double s, // 在车道上的位置(s坐标)
340 const double max, // 最大速度
341 const std::string unit); // 单位
342
343Road *GetRoad( // 获取道路对象
344 const RoadId road_id); // 道路标识符
345
346Lane *GetLane( // 获取车道对象
347 const RoadId road_id, // 道路标识符
348 const LaneId lane_id, // 车道标识符
349 const double s); // 在车道上的位置(s坐标)
350
351// 从控制器解析器调用
352 void CreateController( // 创建控制器
353 const ContId controller_id, // 控制器标识符
354 const std::string controller_name, // 控制器名称
355 const uint32_t controller_sequence, // 控制器序列号
356 const std::set<road::SignId>&& signals // 控制器信号集合
357 );
358
359void SetGeoReference(const geom::GeoLocation &geo_reference) { // 设置地理参考
360 _map_data._geo_reference = geo_reference; // 更新地图数据中的地理参考
361}
362
363private:
364
365 MapData _map_data; // 地图数据
366
367 /// Create the pointers between RoadSegments based on the ids. // 根据标识符创建道路段之间的指针
369
370 /// Create the bounding boxes of each junction // 创建每个交叉口的边界框
372
373 geom::Transform ComputeSignalTransform(std::unique_ptr<Signal> &signal, MapData &data); // 计算信号变换
374
375 /// Solves the signal references in the road // 解决道路中的信号引用
377
378 /// Solve the references between Controllers and Juntions // 解决控制器和交叉口之间的引用
380
381 /// Compute the conflicts of the roads (intersecting roads) // 计算道路冲突(相交道路)
383
384 /// Generates a default validity field for signal references with missing validity record in OpenDRIVE // 为缺少有效性记录的信号引用生成默认有效性字段
386
387 /// Removes signal references with lane validity equal to [0,0] // 移除车道有效性等于[0,0]的信号引用
388 /// as they have no effect on any road
390
391 /// Checks signals overlapping driving lanes and emits a warning // 检查重叠驾驶车道的信号并发出警告
393
394 /// Return the pointer to a lane object. // 返回车道对象的指针
395 Lane *GetEdgeLanePointer(RoadId road_id, bool from_start, LaneId lane_id);
396
397 /// Return a list of pointers to all lanes from a lane (using road and // 返回从某车道到所有车道的指针列表(使用道路和
398 /// junction info). // 交叉口信息)
399 std::vector<Lane *> GetLaneNext(
400 RoadId road_id, // 道路标识符
401 SectionId section_id, // 段落标识符
402 LaneId lane_id); // 车道标识符
403
404 std::vector<std::pair<RoadId, LaneId>> GetJunctionLanes( // 获取交叉口车道
405 JuncId junction_id, // 交叉口标识符
406 RoadId road_id, // 道路标识符
407 LaneId lane_id); // 车道标识符
408
409 /// Map to temporary store all the road and lane infos until the map is // 用于临时存储所有道路和车道信息,直到地图构建完成,因此可以一起添加
410 /// built, so they can be added all together.
411 std::unordered_map<Road *, std::vector<std::unique_ptr<element::RoadInfo>>>
412 _temp_road_info_container; // 临时道路信息容器
413
414 std::unordered_map<Lane *, std::vector<std::unique_ptr<element::RoadInfo>>>
415 _temp_lane_info_container; // 临时车道信息容器
416
417 std::unordered_map<SignId, std::unique_ptr<Signal>>
418 _temp_signal_container; // 临时信号容器
419
420 std::vector<element::RoadInfoSignal*> _temp_signal_reference_container; // 临时信号引用容器
421
422}; // 类结束
423
424} // namespace road
425} // namespace carla
LaneType
可以作为标志使用
Definition Lane.h:29
std::unordered_map< SignId, std::unique_ptr< Signal > > _temp_signal_container
Definition MapBuilder.h:418
void AddRoadGeometryArc(carla::road::Road *road, const double s, const double x, const double y, const double hdg, const double length, const double curvature)
void CreateController(const ContId controller_id, const std::string controller_name, const uint32_t controller_sequence, const std::set< road::SignId > &&signals)
carla::road::Lane * AddRoadSectionLane(carla::road::LaneSection *section, const LaneId lane_id, const uint32_t lane_type, const bool lane_level, const LaneId predecessor, const LaneId successor)
void AddSignalPositionRoad(const SignId signal_id, const RoadId road_id, const double s, const double t, const double zOffset, const double hOffset, const double pitch, const double roll)
void AddSignalPositionInertial(const SignId signal_id, const double x, const double y, const double z, const double hdg, const double pitch, const double roll)
void CreateRoadSpeed(Road *road, const double s, const std::string type, const double max, const std::string unit)
carla::road::Road * AddRoad(const RoadId road_id, const std::string name, const double length, const JuncId junction_id, const RoadId predecessor, const RoadId successor)
void CreateSectionOffset(Road *road, const double s, const double a, const double b, const double c, const double d)
void AddJunctionController(const JuncId junction_id, std::set< ContId > &&controllers)
carla::road::LaneSection * AddRoadSection(carla::road::Road *road, const SectionId id, const double s)
void CreateLaneAccess(Lane *lane, const double s, const std::string restriction)
void AddRoadObjectCrosswalk(Road *road, const std::string name, const double s, const double t, const double zOffset, const double hdg, const double pitch, const double roll, const std::string orientation, const double width, const double length, const std::vector< road::element::CrosswalkPoint > points)
void CreateLaneHeight(Lane *lane, const double s, const double inner, const double outer)
geom::Transform ComputeSignalTransform(std::unique_ptr< Signal > &signal, MapData &data)
Lane * GetLane(const RoadId road_id, const LaneId lane_id, const double s)
void CreateLaneBorder(Lane *lane, const double s, const double a, const double b, const double c, const double d)
void ComputeJunctionRoadConflicts(Map &map)
Compute the conflicts of the roads (intersecting roads) // 计算道路冲突(相交道路)
void AddValidityToSignalReference(element::RoadInfoSignal *signal_reference, const LaneId from_lane, const LaneId to_lane)
void CreateLaneRule(Lane *lane, const double s, const std::string value)
void SetGeoReference(const geom::GeoLocation &geo_reference)
Definition MapBuilder.h:359
void SolveControllerAndJuntionReferences()
Solve the references between Controllers and Juntions // 解决控制器和交叉口之间的引用
void AddRoadElevationProfile(Road *road, const double s, const double a, const double b, const double c, const double d)
boost::optional< Map > Build()
void AddJunction(const JuncId id, const std::string name)
void CreateLaneSpeed(Lane *lane, const double s, const double max, const std::string unit)
std::unordered_map< Road *, std::vector< std::unique_ptr< element::RoadInfo > > > _temp_road_info_container
Map to temporary store all the road and lane infos until the map is // 用于临时存储所有道路和车道信息,直到地图构建完成,因此可以一...
Definition MapBuilder.h:412
void AddLaneLink(const JuncId junction_id, const ConId connection_id, const LaneId from, const LaneId to)
void AddDependencyToSignal(const SignId signal_id, const std::string dependency_id, const std::string dependency_type)
void AddRoadGeometryParamPoly3(carla::road::Road *road, const double s, const double x, const double y, const double hdg, const double length, const double aU, const double bU, const double cU, const double dU, const double aV, const double bV, const double cV, const double dV, const std::string p_range)
std::vector< std::pair< RoadId, LaneId > > GetJunctionLanes(JuncId junction_id, RoadId road_id, LaneId lane_id)
void RemoveZeroLaneValiditySignalReferences()
Removes signal references with lane validity equal to [0,0] // 移除车道有效性等于[0,0]的信号引用 as they have no ef...
void CreateRoadMarkTypeLine(Lane *lane, const int road_mark_id, const double length, const double space, const double tOffset, const double s, const std::string rule, const double width)
void AddRoadSection(const RoadId road_id, const SectionId section_index, const double s, const double a, const double b, const double c, const double d)
void CreateJunctionBoundingBoxes(Map &map)
Create the bounding boxes of each junction // 创建每个交叉口的边界框
element::RoadInfoSignal * AddSignalReference(Road *road, const SignId signal_id, const double s_position, const double t_position, const std::string signal_reference_orientation)
std::unordered_map< Lane *, std::vector< std::unique_ptr< element::RoadInfo > > > _temp_lane_info_container
Definition MapBuilder.h:415
std::vector< element::RoadInfoSignal * > _temp_signal_reference_container
Definition MapBuilder.h:420
void AddRoadGeometryPoly3(carla::road::Road *road, const double s, const double x, const double y, const double hdg, const double length, const double a, const double b, const double c, const double d)
void GenerateDefaultValiditiesForSignalReferences()
Generates a default validity field for signal references with missing validity record in OpenDRIVE //...
void AddConnection(const JuncId junction_id, const ConId connection_id, const RoadId incoming_road, const RoadId connecting_road)
element::RoadInfoSignal * AddSignal(Road *road, const SignId signal_id, const double s, const double t, const std::string name, const std::string dynamic, const std::string orientation, const double zOffset, const std::string country, const std::string type, const std::string subtype, const double value, const std::string unit, const double height, const double width, const std::string text, const double hOffset, const double pitch, const double roll)
void CreateRoadMark(Lane *lane, const int road_mark_id, const double s, const std::string type, const std::string weight, const std::string color, const std::string material, const double width, const std::string lane_change, const double height, const std::string type_name, const double type_width)
std::vector< Lane * > GetLaneNext(RoadId road_id, SectionId section_id, LaneId lane_id)
Return a list of pointers to all lanes from a lane (using road and // 返回从某车道到所有车道的指针列表(使用道路和 junction...
void CreateLaneWidth(Lane *lane, const double s, const double a, const double b, const double c, const double d)
void SolveSignalReferencesAndTransforms()
Solves the signal references in the road // 解决道路中的信号引用
void CreateLaneVisibility(Lane *lane, const double s, const double forward, const double back, const double left, const double right)
void CreatePointersBetweenRoadSegments()
Create the pointers between RoadSegments based on the ids. // 根据标识符创建道路段之间的指针
Road * GetRoad(const RoadId road_id)
void SetRoadLaneLink(const RoadId road_id, const SectionId section_index, const LaneId lane_id, const Lane::LaneType lane_type, const bool lane_level, const LaneId predecessor, const LaneId successor)
void CreateLaneMaterial(Lane *lane, const double s, const std::string surface, const double friction, const double roughness)
void CheckSignalsOnRoads(Map &map)
Checks signals overlapping driving lanes and emits a warning // 检查重叠驾驶车道的信号并发出警告
void AddRoadGeometrySpiral(carla::road::Road *road, const double s, const double x, const double y, const double hdg, const double length, const double curvStart, const double curvEnd)
void AddRoadGeometryLine(carla::road::Road *road, const double s, const double x, const double y, const double hdg, const double length)
Lane * GetEdgeLanePointer(RoadId road_id, bool from_start, LaneId lane_id)
Return the pointer to a lane object. // 返回车道对象的指针
geom::GeoLocation _geo_reference
Definition MapData.h:92
uint32_t SectionId
Definition RoadTypes.h:29
int32_t JuncId
Definition RoadTypes.h:23
std::string ContId
Definition RoadTypes.h:41
int32_t LaneId
Definition RoadTypes.h:26
uint32_t RoadId
Definition RoadTypes.h:20
std::string SignId
Definition RoadTypes.h:35
uint32_t ConId
Definition RoadTypes.h:38
CARLA模拟器的主命名空间。
Definition Carla.cpp:139