CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
road
road/Lane.h
Go to the documentation of this file.
1
// Copyright (c) 2026 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
"
10
#include "
carla/geom/Transform.h
"
11
#include "
carla/road/InformationSet.h
"
12
#include "
carla/road/RoadTypes.h
"
13
14
#include <vector>
15
#include <iostream>
16
#include <memory>
17
18
namespace
carla
{
19
namespace
road
{
20
21
class
LaneSection
;
22
class
MapBuilder
;
23
class
Road
;
24
25
class
Lane
:
private
MovableNonCopyable
{
26
public
:
27
28
/// Can be used as flags
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,
42
Special2 = 0x1 << 12,
43
Special3 = 0x1 << 13,
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
// 0xFFFFFFFE
52
};
53
54
public
:
55
56
Lane
() =
default
;
57
58
Lane
(
59
LaneSection
*lane_section,
60
LaneId
id
,
61
std::vector<std::unique_ptr<element::RoadInfo>> &&info)
62
:
_lane_section
(lane_section),
63
_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
;
73
74
LaneType
GetType
()
const
;
75
76
bool
GetLevel
()
const
;
77
78
template
<
typename
T>
79
const
T *
GetInfo
(
const
double
s)
const
{
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
{
99
return
_successor
;
100
}
101
102
LaneId
GetPredecessor
()
const
{
103
return
_predecessor
;
104
}
105
106
double
GetDistance
()
const
;
107
108
double
GetLength
()
const
;
109
110
/// Returns the total lane width given a s
111
double
GetWidth
(
const
double
s)
const
;
112
113
/// Checks whether the geometry is straight or not
114
bool
IsStraight
()
const
;
115
116
geom::Transform
ComputeTransform
(
const
double
s)
const
;
117
118
/// Computes the location of the edges given a s
119
std::pair<geom::Vector3D, geom::Vector3D>
GetCornerPositions
(
120
const
double
s,
const
float
extra_width = 0.f)
const
;
121
122
bool
IsPositiveDirection
()
const
;
123
124
private
:
125
126
friend
MapBuilder
;
127
128
LaneSection
*
_lane_section
=
nullptr
;
129
130
LaneId
_id
= 0;
131
132
InformationSet
_info
;
133
134
LaneType
_type
=
LaneType::None
;
135
136
bool
_level
=
false
;
137
138
LaneId
_successor
= 0;
139
140
LaneId
_predecessor
= 0;
141
142
std::vector<Lane *>
_next_lanes
;
143
144
std::vector<Lane *>
_prev_lanes
;
145
};
146
147
}
// road
148
}
// carla
DEBUG_ASSERT
#define DEBUG_ASSERT(predicate)
Definition
Debug.h:66
InformationSet.h
Mesh.h
RoadTypes.h
carla::MovableNonCopyable::MovableNonCopyable
MovableNonCopyable()=default
carla::geom::Transform
A rigid transform in CARLA's / Unreal's left-handed frame: x forward, y right, z up,...
Definition
geom/Transform.h:32
carla::road::InformationSet
Definition
InformationSet.h:20
carla::road::InformationSet::GetInfo
const T * GetInfo(const double s) const
Returns single info given a type and a distance (s) from the start of the road.
Definition
InformationSet.h:42
carla::road::InformationSet::GetInfos
std::vector< const T * > GetInfos() const
Return all infos given a type from the start of the road.
Definition
InformationSet.h:30
carla::road::LaneSection
Definition
road/LaneSection.h:24
carla::road::Lane::IsStraight
bool IsStraight() const
Checks whether the geometry is straight or not.
Definition
road/Lane.cpp:67
carla::road::Lane::GetRoad
Road * GetRoad() const
Definition
road/Lane.cpp:29
carla::road::Lane::GetNextLanes
const std::vector< Lane * > & GetNextLanes() const
Definition
road/Lane.h:90
carla::road::Lane::_successor
LaneId _successor
Definition
road/Lane.h:138
carla::road::Lane::_next_lanes
std::vector< Lane * > _next_lanes
Definition
road/Lane.h:142
carla::road::Lane::_info
InformationSet _info
Definition
road/Lane.h:132
carla::road::Lane::GetType
LaneType GetType() const
Definition
road/Lane.cpp:38
carla::road::Lane::GetWidth
double GetWidth(const double s) const
Returns the total lane width given a s.
Definition
road/Lane.cpp:58
carla::road::Lane::Lane
Lane()=default
carla::road::Lane::ComputeTransform
geom::Transform ComputeTransform(const double s) const
Definition
road/Lane.cpp:131
carla::road::Lane::_predecessor
LaneId _predecessor
Definition
road/Lane.h:140
carla::road::Lane::GetInfo
const T * GetInfo(const double s) const
Definition
road/Lane.h:79
carla::road::Lane::GetLaneSection
const LaneSection * GetLaneSection() const
Definition
road/Lane.cpp:25
carla::road::Lane::MapBuilder
friend MapBuilder
Definition
road/Lane.h:126
carla::road::Lane::LaneType
LaneType
Can be used as flags.
Definition
road/Lane.h:29
carla::road::Lane::LaneType::None
@ None
Definition
road/Lane.h:30
carla::road::Lane::GetPredecessor
LaneId GetPredecessor() const
Definition
road/Lane.h:102
carla::road::Lane::GetLevel
bool GetLevel() const
Definition
road/Lane.cpp:42
carla::road::Lane::GetSuccessor
LaneId GetSuccessor() const
Definition
road/Lane.h:98
carla::road::Lane::GetInfos
std::vector< const T * > GetInfos() const
Definition
road/Lane.h:85
carla::road::Lane::Lane
Lane(LaneSection *lane_section, LaneId id, std::vector< std::unique_ptr< element::RoadInfo > > &&info)
Definition
road/Lane.h:58
carla::road::Lane::_lane_section
LaneSection * _lane_section
Definition
road/Lane.h:128
carla::road::Lane::_id
LaneId _id
Definition
road/Lane.h:130
carla::road::Lane::GetDistance
double GetDistance() const
Definition
road/Lane.cpp:46
carla::road::Lane::GetCornerPositions
std::pair< geom::Vector3D, geom::Vector3D > GetCornerPositions(const double s, const float extra_width=0.f) const
Computes the location of the edges given a s.
Definition
road/Lane.cpp:216
carla::road::Lane::GetId
LaneId GetId() const
Definition
road/Lane.cpp:34
carla::road::Lane::GetPreviousLanes
const std::vector< Lane * > & GetPreviousLanes() const
Definition
road/Lane.h:94
carla::road::Lane::IsPositiveDirection
bool IsPositiveDirection() const
Definition
road/Lane.cpp:291
carla::road::Lane::GetLength
double GetLength() const
Definition
road/Lane.cpp:51
carla::road::Lane::_prev_lanes
std::vector< Lane * > _prev_lanes
Definition
road/Lane.h:144
carla::road::Lane::_level
bool _level
Definition
road/Lane.h:136
carla::road::Lane::_type
LaneType _type
Definition
road/Lane.h:134
carla::road::MapBuilder
Definition
MapBuilder.h:22
carla::road::Road
Definition
road/Road.h:32
Transform.h
carla::road
Definition
SignComponent.h:23
carla::road::LaneId
int32_t LaneId
Definition
RoadTypes.h:19
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
std
Definition
CarlaRecorderCollision.h:31
Generated by
1.18.0