CARLA
 
载入中...
搜索中...
未找到
LaneSection.cpp
浏览该文件的文档.
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
10namespace carla {
11namespace 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
#define DEBUG_ASSERT(predicate)
Definition Debug.h:66
SectionId GetId() const
double GetDistance() const
Lane * GetLane(const LaneId id)
std::map< LaneId, Lane > _lanes
Definition LaneSection.h:61
std::vector< Lane * > GetLanesOfType(Lane::LaneType type)
const SectionId _id
Definition LaneSection.h:55
std::map< LaneId, Lane > & GetLanes()
LaneType
Can be used as flags
Definition Lane.h:29
uint32_t SectionId
Definition RoadTypes.h:21
int32_t LaneId
Definition RoadTypes.h:19
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133