ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
navigation_border_observer.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  * Robert Markowski - initial API and implementation
13  ********************************************************************************/
14 
15 
16 #pragma once
17 
18 #include "adore/mad/com_patterns.h"
21 
22 namespace adore
23 {
24  namespace env
25  {
26  namespace BorderBased
27  {
29  {
30  private:
33 
34  public:
36  {
38  m_finishedUpdating = false;
39  }
40  void init(BorderSet * set)
41  {
42  set->deepBorderCopy(*dynamic_cast<BorderSet*>(this));
43  //auto it = set.getAllBorders();
44  //for(;it.first!=it.second;it.first++)
45  //{
46  // auto border = it.first->second;
47  // insert_border(new Border(*border));
48  //}
49  }
50  virtual void update() override
51  {
52  bool relevantUpdateFound = false;
53  while (feed_->hasNext())
54  {
55  /*
56  getting old ID and new border
57  check whether there is a relevant change in the borderset (new border added or relevant type change)
58  delete border with old ID
59  */
60  // reading feed
61  Border* b = new Border();
62  BorderID oldID;
63  feed_->getNext(*b);
64  LOG_T("Nav received: %s\t%i", b->m_id.toString().c_str(), static_cast<int>(b->m_type));
65 
66  // process feed information
67  // if the current border has a relevant type and doesn't exist in border set, a relevant update was found
68  if(b->typeIsChangeable() && !hasBorder(b))
69  {
70  relevantUpdateFound = true;
71  }
72  // if oldID exists in border set, remove border with that id
73  if(hasBorder(oldID))
74  {
75  erase_border(oldID);
76  }
77  insert_border(b,true);
78  }
79  m_finishedUpdating = !relevantUpdateFound && m_changedBordersDuringLastUpdate;
80  m_changedBordersDuringLastUpdate = relevantUpdateFound;
81  }
83  {
84  return m_finishedUpdating;
85  }
86  };
87  }
88  }
89 }
Definition: border_observer.h:29
efficiently store borders in boost R-tree
Definition: borderset.h:99
void insert_border(Border *b, bool force_insert=false)
insert new border into this
Definition: borderset.h:225
bool hasBorder(const BorderID &id) const
check whether a border exists in the set
Definition: borderset.h:966
void erase_border(const BorderID &oldID)
erase border from this
Definition: borderset.h:269
Definition: navigation_border_observer.h:29
bool m_changedBordersDuringLastUpdate
Definition: navigation_border_observer.h:31
void init(BorderSet *set)
Definition: navigation_border_observer.h:40
bool navigationReplanningNecessary()
Definition: navigation_border_observer.h:82
bool m_finishedUpdating
Definition: navigation_border_observer.h:32
NavigationBorderObserver()
Definition: navigation_border_observer.h:35
virtual void update() override
Definition: navigation_border_observer.h:50
AFeed< Border > * feed_
Definition: com_patterns.h:133
#define LOG_T(...)
log on trace level
Definition: csvlog.h:28
void set(T *data, T value, int size)
Definition: adoremath.h:39
Definition: areaofeffectconverter.h:20
This struct identifies a Border by the coordinates of the starting and the end point.
Definition: borderid.h:31
std::string toString() const
Write information of the BorderID to a string.
Definition: borderid.h:131
The border struct contains data of the smallest.
Definition: border.h:62
BorderType::TYPE m_type
Definition: border.h:71
BorderID m_id
Definition: border.h:68
bool typeIsChangeable()
Check whether type is Changeable.
Definition: border.h:278