CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
road
InformationSet.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/NonCopyable.h
"
10
#include "
carla/road/RoadElementSet.h
"
11
#include "
carla/road/element/RoadInfo.h
"
12
#include "
carla/road/element/RoadInfoIterator.h
"
13
14
#include <vector>
15
#include <memory>
16
17
namespace
carla
{
18
namespace
road
{
19
20
class
InformationSet
:
private
MovableNonCopyable
{
21
public
:
22
23
InformationSet
() =
default
;
24
25
InformationSet
(std::vector<std::unique_ptr<element::RoadInfo>> &&vec)
26
:
_road_set
(
std
::move(vec)) {}
27
28
/// Return all infos given a type from the start of the road
29
template
<
typename
T>
30
std::vector<const T *>
GetInfos
()
const
{
31
std::vector<const T *> vec;
32
auto
it = element::MakeRoadInfoIterator<T>(
_road_set
.GetAll());
33
for
(; !it.IsAtEnd(); ++it) {
34
vec.emplace_back(&*it);
35
}
36
return
vec;
37
}
38
39
/// Returns single info given a type and a distance (s) from
40
/// the start of the road
41
template
<
typename
T>
42
const
T *
GetInfo
(
const
double
s)
const
{
43
auto
it = element::MakeRoadInfoIterator<T>(
_road_set
.GetReverseSubset(s));
44
return
it.IsAtEnd() ? nullptr : &*it;
45
}
46
47
/// Return all infos given a type in a given range of the road
48
template
<
typename
T>
49
std::vector<const T *>
GetInfos
(
const
double
min_s,
const
double
max_s)
const
{
50
std::vector<const T *> vec;
51
if
(min_s < max_s) {
52
auto
it = element::MakeRoadInfoIterator<T>(
53
_road_set
.GetSubsetInRange(min_s, max_s));
//reverse
54
for
(; !it.IsAtEnd(); ++it) {
55
vec.emplace_back(&*it);
56
}
57
}
else
{
58
auto
it = element::MakeRoadInfoIterator<T>(
59
_road_set
.GetReverseSubsetInRange(max_s, min_s));
//reverse
60
for
(; !it.IsAtEnd(); ++it) {
61
vec.emplace_back(&*it);
62
}
63
}
64
return
vec;
65
}
66
67
private
:
68
69
RoadElementSet<std::unique_ptr<element::RoadInfo>
>
_road_set
;
70
};
71
72
}
// road
73
}
// carla
NonCopyable.h
RoadElementSet.h
RoadInfoIterator.h
RoadInfo.h
carla::MovableNonCopyable::MovableNonCopyable
MovableNonCopyable()=default
carla::road::InformationSet::InformationSet
InformationSet()=default
carla::road::InformationSet::GetInfos
std::vector< const T * > GetInfos(const double min_s, const double max_s) const
Return all infos given a type in a given range of the road.
Definition
InformationSet.h:49
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::_road_set
RoadElementSet< std::unique_ptr< element::RoadInfo > > _road_set
Definition
InformationSet.h:69
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::InformationSet::InformationSet
InformationSet(std::vector< std::unique_ptr< element::RoadInfo > > &&vec)
Definition
InformationSet.h:25
carla::road::RoadElementSet
A set of elements ordered by its position on the road.
Definition
RoadElementSet.h:23
carla::road
Definition
SignComponent.h:23
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