ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
map_stopline_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 
19 #include <deque>
20 
21 namespace adore
22 {
23  namespace env
24  {
30  {
33  std::deque<adore::env::BorderBased::BorderID> m_borderQueue;
34 
35  public:
41  {
42  m_localSet.setIsOwner(false);
43  }
44 
51  {
52  m_globalSet = globalSet;
53  globalSet.setIsOwner(false);
54  }
55 
60  void reset()
61  {
62  m_localSet.clear();
63  m_borderQueue.clear();
64  }
74  void run
75  (
76  std::vector<adore::env::BorderBased::Border*> newBorders,
77  std::vector<adore::env::BorderBased::BorderID> outdatedBorders,
78  std::vector<adore::env::BorderBased::StopLine> &newLines,
79  std::vector<adore::env::BorderBased::StopLine> &outdatedLines,
80  int MAX_SEND_NUMBER = 5
81  )
82  {
83  newLines.clear();
84  outdatedLines.clear();
85 
86  /* collect outdated stop lines */
87  for(auto borderID = outdatedBorders.begin(); borderID!=outdatedBorders.end(); borderID++)
88  {
89  if(m_localSet.hasObjects(*borderID))
90  {
91  for(auto it = m_localSet.getObjects(*borderID); it.first!=it.second; it.first++)
92  {
93  outdatedLines.push_back(*(static_cast<adore::env::BorderBased::StopLine*>(it.first->second)));
94  }
95  }
96  }
97  /* remove outdated stop lines from local set */
98  m_localSet.eraseObjectsBorderBased(outdatedBorders);
99 
100 
101  /* collect new stop lines */
102  /* add borders to queue that has to be worked off */
103  for(auto border = newBorders.begin(); border!=newBorders.end(); border++)
104  {
105  m_borderQueue.push_back((*border)->m_id);
106  }
107 
108  /* collect new stop lines from borders in border queue */
109  int newCount = 0;
110  int bCount = 0;
111  for(auto borderId = m_borderQueue.begin(); borderId != m_borderQueue.end(); borderId++)
112  {
113  bCount++;
114  if(!m_localSet.hasObjects(*borderId))
115  {
116  for(auto it = m_globalSet.getObjects(*borderId); it.first!=it.second; it.first++)
117  {
118  newLines.push_back(*(static_cast<adore::env::BorderBased::StopLine*>(it.first->second)));
119  newCount++;
120  m_localSet.insert_object(static_cast<adore::env::BorderBased::StopLine*>(it.first->second));
121  }
122  if(newCount>=MAX_SEND_NUMBER)
123  {
124  break;
125  }
126  }
127  }
128 
129  /* remove all processed borders from border queue */
130  for(;bCount>0;bCount--)
131  {
132  m_borderQueue.pop_front();
133  }
134  }
135  };
136  }
137 }
This class represents a set of objects that are positioned by LanePosition.
Definition: lanepositionedobjectset.h:34
void eraseObjectsBorderBased(const std::vector< Border * > borderSet)
Erase Objects that are positioned on certain borders.
Definition: lanepositionedobjectset.h:178
void insert_object(object *obj, bool remove_duplicates=false, double precision=0.5)
Insert a new object.
Definition: lanepositionedobjectset.h:147
ObjectIteratorPair getObjects(const BorderID &borderID)
Get the begin()- and end()-iterator for objects that are positioned on a certain border.
Definition: lanepositionedobjectset.h:234
bool hasObjects(const BorderID &borderID)
Check whether at least one object is contained that is positioned on a certain Border.
Definition: lanepositionedobjectset.h:212
void setIsOwner(bool isOwner)
Set the owner flag.
Definition: lanepositionedobjectset.h:68
void clear()
Clear the LanePositionedObjectSet.
Definition: lanepositionedobjectset.h:76
This class provide information about stoplines.
Definition: stopline.h:31
manage new and outdated stop lines based on newly visible and no longer visible borders and the last ...
Definition: map_stopline_management.h:30
MapStopLineManagement()
Construct a new Map Stop Line Management object.
Definition: map_stopline_management.h:40
adore::env::BorderBased::LanePositionedObjectSet m_localSet
Definition: map_stopline_management.h:32
void run(std::vector< adore::env::BorderBased::Border * > newBorders, std::vector< adore::env::BorderBased::BorderID > outdatedBorders, std::vector< adore::env::BorderBased::StopLine > &newLines, std::vector< adore::env::BorderBased::StopLine > &outdatedLines, int MAX_SEND_NUMBER=5)
receive newly visible or newly outdated stop lines based on new and outdated borders
Definition: map_stopline_management.h:75
void init(adore::env::BorderBased::LanePositionedObjectSet &globalSet)
initialization routine
Definition: map_stopline_management.h:50
std::deque< adore::env::BorderBased::BorderID > m_borderQueue
Definition: map_stopline_management.h:33
adore::env::BorderBased::LanePositionedObjectSet m_globalSet
Definition: map_stopline_management.h:31
void reset()
clear local sets and pending updates
Definition: map_stopline_management.h:60
Definition: areaofeffectconverter.h:20