CARLA
LaneSection.cpp
Go to the documentation of this file.
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 
8 #include "carla/road/Road.h"
9 
10 namespace carla {
11 namespace road {
12 
13  double LaneSection::GetDistance() const {
14  return _s;
15  }
16 
17  double LaneSection::GetLength() const {
18  const auto *road = GetRoad();
19  DEBUG_ASSERT(road != nullptr);
20  return road->UpperBound(_s) - _s;
21  }
22 
24  return _road;
25  }
26 
28  return _id;
29  }
30 
32  auto search = _lanes.find(id);
33  if (search != _lanes.end()) {
34  return &search->second;
35  }
36  return nullptr;
37  }
38 
39  const Lane *LaneSection::GetLane(const LaneId id) const {
40  auto search = _lanes.find(id);
41  if (search != _lanes.end()) {
42  return &search->second;
43  }
44  return nullptr;
45  }
46 
47  std::map<LaneId, Lane> &LaneSection::GetLanes() {
48  return _lanes;
49  }
50 
51  const std::map<LaneId, Lane> &LaneSection::GetLanes() const {
52  return _lanes;
53  }
54 
55  std::vector<Lane *> LaneSection::GetLanesOfType(Lane::LaneType lane_type) {
56  std::vector<Lane *> drivable_lanes;
57  for (auto &&lane : _lanes) {
58  if ((static_cast<uint32_t>(lane.second.GetType()) & static_cast<uint32_t>(lane_type)) > 0) {
59  drivable_lanes.emplace_back(&lane.second);
60  }
61  }
62  return drivable_lanes;
63  }
64 
65 } // namespace road
66 } // namespace carla
Road * GetRoad() const
Definition: LaneSection.cpp:23
double GetDistance() const
Definition: LaneSection.cpp:13
std::vector< Lane * > GetLanesOfType(Lane::LaneType type)
Definition: LaneSection.cpp:55
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
uint32_t SectionId
Definition: RoadTypes.h:21
std::map< LaneId, Lane > _lanes
Definition: LaneSection.h:61
double GetLength() const
Definition: LaneSection.cpp:17
#define DEBUG_ASSERT(predicate)
Definition: Debug.h:66
SectionId GetId() const
Definition: LaneSection.cpp:27
LaneType
Can be used as flags.
Definition: Lane.h:29
int32_t LaneId
Definition: RoadTypes.h:19
std::map< LaneId, Lane > & GetLanes()
Definition: LaneSection.cpp:47
const SectionId _id
Definition: LaneSection.h:55
Lane * GetLane(const LaneId id)
Definition: LaneSection.cpp:31