ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
bordertrace.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  * Daniel Heß - initial API and implementation
13  ********************************************************************************/
14 
15 #pragma once
17 #include <list>
18 
19 namespace adore
20 {
21  namespace env
22  {
23  namespace BorderBased
24  {
30  {
31  public:
32  typedef std::pair<BorderID,double> DTYPE;
33  typedef std::list<DTYPE> CTYPE;
34  private:
35  CTYPE m_trace;//remembers border ids and their length
37  double m_length;
38  public:
40  BorderTrace(double distance_limit):m_distance_limit(distance_limit),m_length(0.0){}
41  void setDistanceLimit(double distance_limit){m_distance_limit=distance_limit;}
43  void insert(Border& border)
44  {
45  //nothing to do, if the vehicle is matched on the same border as last time
46  if(m_trace.size()>0 && border.m_id==m_trace.front().first)
47  {
48  return;
49  }
50  //test for disonctinuity: if there is a jump, throw away trace
51  if(m_trace.size()>0 && !border.isSuccessorOf(m_trace.front().first))
52  {
53  clear();
54  }
55  //insert the new borderID and add length
56  double L = border.getLength();
57  m_length+=L;
58  m_trace.push_front(std::make_pair(border.m_id,L));
59  //in the following computation of length, back is ignored (as it could be removed)
60  //and front is ignored (as the vehicle could be right at the beginning of front)
61  while(m_length-m_trace.back().second-m_trace.front().second>m_distance_limit)
62  {
63  m_length -= m_trace.back().second;
64  m_trace.pop_back();
65  }
66  }
67  CTYPE::iterator begin(){return m_trace.begin();}
68  CTYPE::iterator end(){return m_trace.end();}
69  CTYPE::reverse_iterator rbegin(){return m_trace.rbegin();}
70  CTYPE::reverse_iterator rend(){return m_trace.rend();}
71  void clear(){m_trace.clear();m_length=0;}
72  DTYPE front(){return m_trace.front();}
73  DTYPE back(){return m_trace.back();}
74 
75  };
76  }
77  }
78 }
Definition: bordertrace.h:30
double getDistanceLimit()
Definition: bordertrace.h:42
CTYPE::reverse_iterator rend()
Definition: bordertrace.h:70
std::pair< BorderID, double > DTYPE
Definition: bordertrace.h:32
BorderTrace()
Definition: bordertrace.h:39
void insert(Border &border)
Definition: bordertrace.h:43
double m_length
Definition: bordertrace.h:37
std::list< DTYPE > CTYPE
Definition: bordertrace.h:33
CTYPE::iterator begin()
Definition: bordertrace.h:67
DTYPE back()
Definition: bordertrace.h:73
double m_distance_limit
Definition: bordertrace.h:36
CTYPE m_trace
Definition: bordertrace.h:35
CTYPE::reverse_iterator rbegin()
Definition: bordertrace.h:69
CTYPE::iterator end()
Definition: bordertrace.h:68
DTYPE front()
Definition: bordertrace.h:72
void setDistanceLimit(double distance_limit)
Definition: bordertrace.h:41
void clear()
Definition: bordertrace.h:71
BorderTrace(double distance_limit)
Definition: bordertrace.h:40
Definition: areaofeffectconverter.h:20
The border struct contains data of the smallest.
Definition: border.h:62
double getLength()
Get the length of the border.
Definition: border.h:703
BorderID m_id
Definition: border.h:68
bool isSuccessorOf(const BorderID &predecessorID)
Check whether border is a direct successors of another border.
Definition: border.h:319