ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
map_tcd_management.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2020 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  ********************************************************************************/
13 
14 
15 #pragma once
16 
17 #include "map_auxiliary.h"
18 #include <adore/env/tcd/tcdset.h>
19 
20 namespace adore
21 {
22  namespace env
23  {
29  {
32  public:
38  {
39  m_localSet.setIsOwner(false);
40  }
46  void init(adore::env::TCDSet &globalSet)
47  {
48  m_globalSet = globalSet;
49  globalSet.setIsOwner(false);
50  }
55  void reset()
56  {
57  m_localSet.clear();
58  }
71  void run(
72  double x, double y, double r,
73  std::vector<adore::env::TrafficControlDevice*> &newTCD,
74  std::vector<adore::env::TrafficControlDevice*> &outdatedTCD,
75  std::vector<adore::env::TTCDTrafficLightTuple> &newTL,
76  std::vector<adore::env::TTCDTrafficLightTuple> &outdatedTL,
77  int MAX_NEW_NUMBER = 5
78  )
79  {
80  newTCD.clear();
81  outdatedTCD.clear();
82  newTL.clear();
83  outdatedTL.clear();
84 
85  auto corners = MAP_AUX::getCornerPoints(x,y,r);
86 
87  /* collect old TCDs/TLs */
88  std::vector<int> delTcdId;
89  for(auto it = m_localSet.getTCDsOutsideRegion(corners.at(0),corners.at(1),corners.at(2),corners.at(3));it.first!=it.second;it.first++)
90  {
91  delTcdId.push_back(it.first->second);
92  adore::env::TrafficControlDevice* tcd = m_localSet.getTCD(it.first->second);
94  {
95  outdatedTL.push_back(m_localSet.getTCDTrafficLight(tcd->getID()));
96  }
97  else
98  {
99  outdatedTCD.push_back(tcd);
100  }
101  }
102  for(auto it = delTcdId.begin(); it!=delTcdId.end();it++)
103  {
104  m_localSet.eraseTCD(*it);
105  }
106 
107  /* collect new TCDs/TLs */
108  for(auto it = m_globalSet.getTCDsInRegion(corners.at(0),corners.at(1),corners.at(2),corners.at(3)); it.first!=it.second; it.first++)
109  {
110  auto tcdId = it.first->second;
111  if(!m_localSet.hasTCD(tcdId))
112  {
113  auto tcd = m_globalSet.getTCD(tcdId);
114  m_localSet.insertTCD(tcd);
116  {
117  auto tcdt = m_globalSet.getTCDTrafficLight(tcdId);
118 
119  m_localSet.setMovementId(std::get<0>(tcdt)->getID(), std::get<1>(tcdt));
120  m_localSet.setJunctionId(std::get<1>(tcdt),std::get<2>(tcdt));
121  newTL.push_back(tcdt);
122 
123  }
124  else
125  {
126  newTCD.push_back(tcd);
127  }
128  }
129  }
130  }
131  };
132  }
133 }
manage visible traffic control devices based on vehicle position and last state of the object
Definition: map_tcd_management.h:29
void run(double x, double y, double r, std::vector< adore::env::TrafficControlDevice * > &newTCD, std::vector< adore::env::TrafficControlDevice * > &outdatedTCD, std::vector< adore::env::TTCDTrafficLightTuple > &newTL, std::vector< adore::env::TTCDTrafficLightTuple > &outdatedTL, int MAX_NEW_NUMBER=5)
get new/outdated traffic control devices / traffic lights based on last object state and current vehi...
Definition: map_tcd_management.h:71
adore::env::TCDSet m_globalSet
Definition: map_tcd_management.h:30
MapTCDManagement()
Construct a new Map T C D Management object.
Definition: map_tcd_management.h:37
void init(adore::env::TCDSet &globalSet)
initialization routine
Definition: map_tcd_management.h:46
void reset()
clear local set
Definition: map_tcd_management.h:55
adore::env::TCDSet m_localSet
Definition: map_tcd_management.h:31
Definition: tcdset.h:34
bool insertTCD(env::TrafficControlDevice *tcd)
Definition: tcdset.h:128
void setMovementId(int tcdId, int movementId)
Definition: tcdset.h:149
void clear()
Definition: tcdset.h:185
bool eraseTCD(int tcdID)
Definition: tcdset.h:165
bool hasTCD(int tcdID)
Definition: tcdset.h:259
void setJunctionId(int movementId, int junctionId)
Definition: tcdset.h:154
ItCoordinate2tcdID getTCDsInRegion(double x0, double x1, double y0, double y1)
Definition: tcdset.h:214
env::TrafficControlDevice * getTCD(int tcdID)
Definition: tcdset.h:264
void setIsOwner(bool b)
Definition: tcdset.h:108
env::TTCDTrafficLightTuple getTCDTrafficLight(int tcdID)
Definition: tcdset.h:273
ItCoordinate2tcdID getTCDsOutsideRegion(double x0, double x1, double y0, double y1)
Definition: tcdset.h:228
Definition: trafficcontroldevice.h:24
int getID() const
Definition: trafficcontroldevice.h:146
TCDType getType() const
Definition: trafficcontroldevice.h:155
@ TRAFFIC_LIGHT
Definition: trafficcontroldevice.h:29
std::vector< double > getCornerPoints(double x, double y, double r)
Get corner points vector from center point and radius.
Definition: map_auxiliary.h:34
x
Definition: adore_set_goal.py:30
y
Definition: adore_set_goal.py:31
r
Definition: adore_suppress_lanechanges.py:209
Definition: areaofeffectconverter.h:20
T1 first
Definition: tcdset.h:43