CARLA
 
载入中...
搜索中...
未找到
Lane.h
浏览该文件的文档.
1// Copyright (c) 2020 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/geom/Mesh.h" // 引入Mesh类的头文件
10#include "carla/geom/Transform.h" // 引入Transform类的头文件
11#include "carla/road/InformationSet.h" // 引入InformationSet类的头文件
12#include "carla/road/RoadTypes.h" // 引入RoadTypes类的头文件
13
14#include <vector> // 引入vector容器
15#include <iostream> // 引入输入输出流
16#include <memory> // 引入智能指针
17
18namespace carla { // 定义carla命名空间
19namespace road { // 定义road命名空间
20
21 class LaneSection; // 前向声明LaneSection类
22 class MapBuilder; // 前向声明MapBuilder类
23 class Road; // 前向声明Road类
24
25 class Lane : private MovableNonCopyable { // 定义Lane类,继承自MovableNonCopyable
26 public:
27
28 /// 可以作为标志使用
29 enum class LaneType : int32_t { // 定义车道类型的枚举
30 None = 0x1, // 无
31 Driving = 0x1 << 1, // 行驶车道
32 Stop = 0x1 << 2, // 停止车道
33 Shoulder = 0x1 << 3, // 应急车道
34 Biking = 0x1 << 4, // 自行车道
35 Sidewalk = 0x1 << 5, // 人行道
36 Border = 0x1 << 6, // 边界
37 Restricted = 0x1 << 7, // 限制
38 Parking = 0x1 << 8, // 停车场
39 Bidirectional = 0x1 << 9, // 双向车道
40 Median = 0x1 << 10, // 中央车道
41 Special1 = 0x1 << 11, // 特殊类型1
42 Special2 = 0x1 << 12, // 特殊类型2
43 Special3 = 0x1 << 13, // 特殊类型3
44 RoadWorks = 0x1 << 14, // 道路施工
45 Tram = 0x1 << 15, // 有轨电车车道
46 Rail = 0x1 << 16, // 铁路车道
47 Entry = 0x1 << 17, // 入口
48 Exit = 0x1 << 18, // 出口
49 OffRamp = 0x1 << 19, // 下匝道
50 OnRamp = 0x1 << 20, // 上匝道
51 Any = -2 // 任意类型
52 };
53
54 public:
55
56 Lane() = default; // 默认构造函数
57
58 Lane( // 带参数的构造函数
59 LaneSection *lane_section, // 车道段指针
60 LaneId id, // 车道ID
61 std::vector<std::unique_ptr<element::RoadInfo>> &&info) // 路面信息的唯一指针向量
62 : _lane_section(lane_section), // 初始化车道段指针
63 _id(id), // 初始化车道ID
64 _info(std::move(info)) { // 移动初始化路面信息
65 DEBUG_ASSERT(lane_section != nullptr); // 调试断言:车道段指针不能为空
66 }
67
68 const LaneSection *GetLaneSection() const; // 获取车道段指针
69
70 Road *GetRoad() const; // 获取道路指针
71
72 LaneId GetId() const; // 获取车道ID
73
74 LaneType GetType() const; // 获取车道类型
75
76 bool GetLevel() const; // 获取车道等级
77
78 template <typename T>
79 const T *GetInfo(const double s) const { // 根据位置s获取信息
80 DEBUG_ASSERT(_lane_section != nullptr); // 调试断言:车道段指针不能为空
81 return _info.GetInfo<T>(s); // 返回指定类型的信息
82 }
83
84 template <typename T>
85 std::vector<const T*> GetInfos() const { // 获取所有信息
86 DEBUG_ASSERT(_lane_section != nullptr); // 调试断言:车道段指针不能为空
87 return _info.GetInfos<T>(); // 返回所有指定类型的信息
88 }
89
90 const std::vector<Lane *> &GetNextLanes() const { // 获取下一车道的引用
91 return _next_lanes; // 返回下一车道列表
92 }
93
94 const std::vector<Lane *> &GetPreviousLanes() const { // 获取前一车道的引用
95 return _prev_lanes; // 返回前一车道列表
96 }
97
98 LaneId GetSuccessor() const { // 获取后继车道ID
99 return _successor; // 返回后继车道ID
100 }
101
102 LaneId GetPredecessor() const { // 获取前驱车道ID
103 return _predecessor; // 返回前驱车道ID
104 }
105
106 double GetDistance() const; // 获取车道的距离
107
108 double GetLength() const; // 获取车道的长度
109
110 /// 返回给定位置s的车道总宽度
111 double GetWidth(const double s) const; // 获取给定位置s的车道宽度
112
113 /// 检查几何形状是否是直线
114 bool IsStraight() const; // 检查车道是否直
115
116 geom::Transform ComputeTransform(const double s) const; // 计算给定位置s的变换
117
118 /// 计算给定位置s的车道边缘位置
119 std::pair<geom::Vector3D, geom::Vector3D> GetCornerPositions( // 获取车道角落位置
120 const double s, const float extra_width = 0.f) const; // 可选额外宽度
121
122 private:
123
124 friend MapBuilder; // 友元类:MapBuilder
125
126 LaneSection *_lane_section = nullptr; // 车道段指针
127
128 LaneId _id = 0; // 车道ID
129
130 InformationSet _info; // 路面信息集合
131
132 LaneType _type = LaneType::None; // 车道类型
133
134 bool _level = false; // 车道等级
135
136 LaneId _successor = 0; // 后继车道ID
137
138 LaneId _predecessor = 0; // 前驱车道ID
139
140 std::vector<Lane *> _next_lanes; // 下一车道列表
141
142 std::vector<Lane *> _prev_lanes; // 前一车道列表
143 };
144
145} // road
146} // carla
#define DEBUG_ASSERT(predicate)
Definition Debug.h:68
这个类用于禁止拷贝构造函数和赋值操作,但允许移动构造函数和赋值操作
const T * GetInfo(const double s) const
返回给定类型和距离s的单一信息
std::vector< const T * > GetInfos() const
返回从道路起点给定类型的所有信息
bool IsStraight() const
检查几何形状是否是直线
Road * GetRoad() const
const std::vector< Lane * > & GetNextLanes() const
Definition Lane.h:90
LaneId _successor
Definition Lane.h:136
std::vector< Lane * > _next_lanes
Definition Lane.h:140
InformationSet _info
Definition Lane.h:130
double GetWidth(const double s) const
返回给定位置s的车道总宽度
geom::Transform ComputeTransform(const double s) const
LaneId _predecessor
Definition Lane.h:138
const T * GetInfo(const double s) const
Definition Lane.h:79
const LaneSection * GetLaneSection() const
friend MapBuilder
Definition Lane.h:124
LaneType
可以作为标志使用
Definition Lane.h:29
LaneId GetPredecessor() const
Definition Lane.h:102
bool GetLevel() const
LaneType GetType() const
LaneId GetSuccessor() const
Definition Lane.h:98
std::vector< const T * > GetInfos() const
Definition Lane.h:85
Lane(LaneSection *lane_section, LaneId id, std::vector< std::unique_ptr< element::RoadInfo > > &&info)
Definition Lane.h:58
LaneSection * _lane_section
Definition Lane.h:126
double GetDistance() const
std::pair< geom::Vector3D, geom::Vector3D > GetCornerPositions(const double s, const float extra_width=0.f) const
计算给定位置s的车道边缘位置
LaneId GetId() const
const std::vector< Lane * > & GetPreviousLanes() const
Definition Lane.h:94
double GetLength() const
std::vector< Lane * > _prev_lanes
Definition Lane.h:142
LaneType _type
Definition Lane.h:132
int32_t LaneId
Definition RoadTypes.h:26
CARLA模拟器的主命名空间。
Definition Carla.cpp:139