14#include <unordered_set>
33 std::vector<SharedPtr<Road>> Junction::GetConnectingRoads()
const {
34 std::vector<SharedPtr<Road>> result;
35 std::unordered_set<road::RoadId> seen;
40 for (
const auto &pair :
junction->GetConnections()) {
42 if (!seen.insert(
road_id).second) {
46 if (
road !=
nullptr) {
47 result.emplace_back(std::move(
road));
53 std::vector<SharedPtr<Road>> Junction::GetAdjacentRoads()
const {
54 std::vector<SharedPtr<Road>> result;
55 std::unordered_set<road::RoadId> seen;
60 for (
const auto &pair :
junction->GetConnections()) {
62 if (!seen.insert(
road_id).second) {
66 if (
road !=
nullptr) {
67 result.emplace_back(std::move(
road));
78 std::vector<SharedPtr<Lane>> Junction::GetNeighbourLanes(
80 bool entering)
const {
81 std::vector<SharedPtr<Lane>> result;
82 std::unordered_set<uint64_t> seen;
85 if (waypoint ==
nullptr) {
89 if (lane ==
nullptr) {
92 const auto neighbours = entering ? lane->GetPreviousLanes() : lane->GetNextLanes();
94 if (neighbour ==
nullptr) {
99 if (
road ==
nullptr ||
road->GetJunctionId() ==
_id) {
102 if (!seen.insert(neighbour->GetUniqueId()).second) {
105 result.emplace_back(neighbour);
126 constexpr double kEpsilon = 1e-3;
128 const double end = start + lane.
GetLength();
129 const bool downstream = entering;
132 return std::max(start, end - kEpsilon);
134 return std::min(end, start + kEpsilon);
137 std::vector<SharedPtr<Waypoint>> Junction::GetNeighbourWaypoints(
139 bool entering)
const {
140 std::vector<SharedPtr<Waypoint>> result;
143 if (waypoint !=
nullptr) {
144 result.emplace_back(std::move(waypoint));
std::map< long long, long long > _parent
std::map< std::string, unsigned int > road
std::map< std::string, unsigned int > junction
std::vector< SharedPtr< Lane > > GetNeighbourLanes(road::Lane::LaneType type, bool entering) const
Shared implementation of GetEntryLanes / GetExitLanes.
std::vector< std::pair< SharedPtr< Waypoint >, SharedPtr< Waypoint > > > GetWaypoints(road::Lane::LaneType type=road::Lane::LaneType::Driving) const
std::vector< SharedPtr< Waypoint > > GetNeighbourWaypoints(road::Lane::LaneType type, bool entering) const
Shared implementation of GetEntryWaypoints / GetExitWaypoints.
carla::road::JuncId GetId() const
geom::BoundingBox _bounding_box
SharedPtr< const Map > _parent
A single OpenDRIVE lane, identified by (road id, lane section id, lane id).
double GetDistance() const
The s coordinate, along the road, at which this lane's section begins.
double GetLength() const
Length of the lane, in metres.
bool IsPositiveDirection() const
Whether the lane runs along increasing s (a right-hand lane, id < 0).
LaneType
Can be used as flags.
static double JunctionSideDistance(const Lane &lane, bool entering)
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< T > SharedPtr