CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
client
client/LaneSection.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/Memory.h
"
10
#include "
carla/NonCopyable.h
"
11
#include "
carla/road/Lane.h
"
12
#include "
carla/road/RoadTypes.h
"
13
14
#include <vector>
15
16
namespace
carla
{
17
namespace
client
{
18
19
class
Map
;
20
class
Road
;
21
class
Lane
;
22
23
/// A stretch of road over which the lane layout does not change.
24
///
25
/// An OpenDRIVE road is divided along s into lane sections; lanes are added
26
/// or dropped only at a section boundary. This is why a lane's identity
27
/// carries a section id, and why Lane::GetNextLanes() can step into a
28
/// different section.
29
class
LaneSection
30
:
public
EnableSharedFromThis
<LaneSection>,
31
private
NonCopyable
{
32
public
:
33
34
road::SectionId
GetId
()
const
{
35
return
_section_id
;
36
}
37
38
road::RoadId
GetRoadId
()
const
{
39
return
_road_id
;
40
}
41
42
/// Unique id of this section within its map, for use as a dictionary key.
43
uint64_t
GetUniqueId
()
const
;
44
45
SharedPtr<Road>
GetRoad
()
const
;
46
47
/// The s coordinate, along the road, at which this section begins.
48
double
GetDistance
()
const
;
49
50
/// Length of the section, in metres.
51
double
GetLength
()
const
;
52
53
/// Every lane in this section of the given type. The centre lane (id 0)
54
/// carries no width and is never returned.
55
std::vector<SharedPtr<Lane>>
GetLanes
(
56
road::Lane::LaneType
type =
road::Lane::LaneType::Driving
)
const
;
57
58
/// The lane with this id, or nullptr when the section has no such lane.
59
SharedPtr<Lane>
GetLane
(
road::LaneId
lane_id)
const
;
60
61
bool
ContainsLane
(
road::LaneId
lane_id)
const
;
62
63
/// The next section along the road, or nullptr at the end.
64
SharedPtr<LaneSection>
GetNextSection
()
const
;
65
66
/// The previous section along the road, or nullptr at the start.
67
SharedPtr<LaneSection>
GetPreviousSection
()
const
;
68
69
bool
operator==
(
const
LaneSection
&rhs)
const
{
70
return
(
_road_id
== rhs.
_road_id
) && (
_section_id
== rhs.
_section_id
);
71
}
72
73
bool
operator!=
(
const
LaneSection
&rhs)
const
{
74
return
!(*
this
== rhs);
75
}
76
77
private
:
78
79
friend
class
Map
;
80
friend
class
Road
;
81
friend
class
Lane
;
82
83
LaneSection
(
SharedPtr<const Map>
parent,
road::RoadId
road_id,
road::SectionId
section_id)
84
:
_parent
(
std
::move(parent)),
85
_road_id
(road_id),
86
_section_id
(section_id) {}
87
88
SharedPtr<const Map>
_parent
;
89
90
road::RoadId
_road_id
;
91
92
road::SectionId
_section_id
;
93
};
94
95
}
// namespace client
96
}
// namespace carla
NonCopyable.h
Memory.h
RoadTypes.h
carla::NonCopyable::NonCopyable
NonCopyable()=default
carla::client::LaneSection::GetDistance
double GetDistance() const
The s coordinate, along the road, at which this section begins.
Definition
client/LaneSection.cpp:43
carla::client::LaneSection::Road
friend class Road
Definition
client/LaneSection.h:80
carla::client::LaneSection::ContainsLane
bool ContainsLane(road::LaneId lane_id) const
Definition
client/LaneSection.cpp:75
carla::client::LaneSection::GetRoad
SharedPtr< Road > GetRoad() const
Definition
client/LaneSection.cpp:39
carla::client::LaneSection::operator!=
bool operator!=(const LaneSection &rhs) const
Definition
client/LaneSection.h:73
carla::client::LaneSection::_section_id
road::SectionId _section_id
Definition
client/LaneSection.h:92
carla::client::LaneSection::_road_id
road::RoadId _road_id
Definition
client/LaneSection.h:90
carla::client::LaneSection::GetId
road::SectionId GetId() const
Definition
client/LaneSection.h:34
carla::client::LaneSection::GetNextSection
SharedPtr< LaneSection > GetNextSection() const
The next section along the road, or nullptr at the end.
Definition
client/LaneSection.cpp:80
carla::client::LaneSection::GetLanes
std::vector< SharedPtr< Lane > > GetLanes(road::Lane::LaneType type=road::Lane::LaneType::Driving) const
Every lane in this section of the given type.
Definition
client/LaneSection.cpp:53
carla::client::LaneSection::_parent
SharedPtr< const Map > _parent
Definition
client/LaneSection.h:88
carla::client::LaneSection::GetRoadId
road::RoadId GetRoadId() const
Definition
client/LaneSection.h:38
carla::client::LaneSection::GetLane
SharedPtr< Lane > GetLane(road::LaneId lane_id) const
The lane with this id, or nullptr when the section has no such lane.
Definition
client/LaneSection.cpp:71
carla::client::LaneSection::GetPreviousSection
SharedPtr< LaneSection > GetPreviousSection() const
The previous section along the road, or nullptr at the start.
Definition
client/LaneSection.cpp:94
carla::client::LaneSection::GetUniqueId
uint64_t GetUniqueId() const
Unique id of this section within its map, for use as a dictionary key.
Definition
client/LaneSection.cpp:35
carla::client::LaneSection::Map
friend class Map
Definition
client/LaneSection.h:79
carla::client::LaneSection::Lane
friend class Lane
Definition
client/LaneSection.h:81
carla::client::LaneSection::operator==
bool operator==(const LaneSection &rhs) const
Definition
client/LaneSection.h:69
carla::client::LaneSection::GetLength
double GetLength() const
Length of the section, in metres.
Definition
client/LaneSection.cpp:48
carla::client::LaneSection::LaneSection
LaneSection(SharedPtr< const Map > parent, road::RoadId road_id, road::SectionId section_id)
Definition
client/LaneSection.h:83
carla::client::Lane
A single OpenDRIVE lane, identified by (road id, lane section id, lane id).
Definition
client/Lane.h:37
carla::client::Map
Definition
client/Map.h:32
carla::client::Road
An OpenDRIVE road: a run of carriageway divided along s into lane sections, each holding the lanes.
Definition
client/Road.h:36
carla::road::Lane::LaneType
LaneType
Can be used as flags.
Definition
road/Lane.h:29
carla::road::Lane::LaneType::Driving
@ Driving
Definition
road/Lane.h:31
carla::client
Definition
BasicAgent.h:24
carla::road::SectionId
uint32_t SectionId
Definition
RoadTypes.h:21
carla::road::LaneId
int32_t LaneId
Definition
RoadTypes.h:19
carla::road::RoadId
uint32_t RoadId
Definition
RoadTypes.h:15
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::EnableSharedFromThis
std::enable_shared_from_this< T > EnableSharedFromThis
Definition
Memory.h:21
carla::SharedPtr
std::shared_ptr< T > SharedPtr
Definition
Memory.h:15
std
Definition
CarlaRecorderCollision.h:31
Lane.h
Generated by
1.18.0