CARLA
Loading...
Searching...
No Matches
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"
13
14#include <vector>
15
16namespace carla {
17namespace 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.
30 : public EnableSharedFromThis<LaneSection>,
31 private NonCopyable {
32 public:
33
35 return _section_id;
36 }
37
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
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(
57
58 /// The lane with this id, or nullptr when the section has no such lane.
60
61 bool ContainsLane(road::LaneId lane_id) const;
62
63 /// The next section along the road, or nullptr at the end.
65
66 /// The previous section along the road, or nullptr at the start.
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
84 : _parent(std::move(parent)),
86 _section_id(section_id) {}
87
89
91
93 };
94
95} // namespace client
96} // namespace carla
std::string road_id
Definition LaneGraph.cpp:39
Inherit (privately) to suppress copy/move construction and assignment.
A stretch of road over which the lane layout does not change.
double GetDistance() const
The s coordinate, along the road, at which this section begins.
bool ContainsLane(road::LaneId lane_id) const
SharedPtr< Road > GetRoad() const
bool operator!=(const LaneSection &rhs) const
road::SectionId GetId() const
SharedPtr< LaneSection > GetNextSection() const
The next section along the road, or nullptr at the end.
std::vector< SharedPtr< Lane > > GetLanes(road::Lane::LaneType type=road::Lane::LaneType::Driving) const
Every lane in this section of the given type.
SharedPtr< const Map > _parent
road::RoadId GetRoadId() const
SharedPtr< Lane > GetLane(road::LaneId lane_id) const
The lane with this id, or nullptr when the section has no such lane.
SharedPtr< LaneSection > GetPreviousSection() const
The previous section along the road, or nullptr at the start.
uint64_t GetUniqueId() const
Unique id of this section within its map, for use as a dictionary key.
bool operator==(const LaneSection &rhs) const
double GetLength() const
Length of the section, in metres.
LaneSection(SharedPtr< const Map > parent, road::RoadId road_id, road::SectionId section_id)
A single OpenDRIVE lane, identified by (road id, lane section id, lane id).
Definition client/Lane.h:37
An OpenDRIVE road: a run of carriageway divided along s into lane sections, each holding the lanes.
Definition client/Road.h:36
LaneType
Can be used as flags.
Definition road/Lane.h:29
uint32_t RoadId
Definition RoadTypes.h:15
int32_t LaneId
Definition RoadTypes.h:19
uint32_t SectionId
Definition RoadTypes.h:21
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< T > SharedPtr
Definition Memory.h:15