ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
anominalplannerinformation.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
16 #include "anominalplanner.h"
17 #include <vector>
18 
19 namespace adore
20 {
21  namespace fun
22  {
27  {
28  public:
30  virtual bool getReferenceIfAvailable(int dim, int der, double t,double s,double ds,double& ref) const = 0;
32  virtual double getUB(int dim, int der, double t,double s,double ds) const = 0;
34  virtual double getLB(int dim, int der, double t,double s,double ds) const = 0;
36  virtual void update(double t0,double s0,double ds0) =0;
37  };
38 
44  template<int N,int D>
46  {
47  private:
48  typedef std::vector<ANominalConstraint*> TCset;
49  typedef std::vector<ANominalReference*> TRset;
50  typedef std::vector<ANominalPlannerInformation*> TIset;
51  TCset bound_[D*N*2];
52  TRset ref_[D*N];
54  double unbound_;
55 
56  public:
62  {
63  unbound_ = 1e5;
64  }
69  {
70  ref_[r->getDimension()*N+r->getDerivative()].push_back(r);
71  }
76  {
77  int id = c->getDirection()==ANominalConstraint::UB?0:1;
78  bound_[c->getDimension()*N*2 + c->getDerivative()*2 + id].push_back(c);
79  }
84  {
85  int id = c->getDirection()==ANominalConstraint::UB?0:1;
86  TCset::iterator it;
87  it = std::find(
88  bound_[c->getDimension()*N*2 + c->getDerivative()*2 + id].begin(),
89  bound_[c->getDimension()*N*2 + c->getDerivative()*2 + id].end(),
90  c);
91  if (it != bound_[c->getDimension()*N*2 + c->getDerivative()*2 + id].end())
92  {
93  bound_[c->getDimension()*N*2 + c->getDerivative()*2 + id].erase(it);
94  return true;
95  }
96  return false;
97  }
102  {
103  TRset::iterator it;
104  it = std::find(
105  ref_[r->getDimension()*N + r->getDerivative()].begin(),
106  ref_[r->getDimension()*N + r->getDerivative()].end(),
107  r);
108  if (it != ref_[r->getDimension()*N + r->getDerivative()].end())
109  {
110  ref_[r->getDimension()*N + r->getDerivative()].erase(it);
111  return true;
112  }
113  return false;
114  }
119  {
120  subsets_.push_back(value);
121  }
122 
127  {
128  auto it = std::find(subsets_.begin(), subsets_.end(), value);
129  if (it != subsets_.end())
130  {
131  subsets_.erase(it);
132  return true;
133  }
134  return false;
135  }
136  public:
147  virtual bool getReferenceIfAvailable(int dim, int der, double t,double s,double ds,double& ref) const override
148  {
149  for(ANominalReference* r:ref_[dim*N+der])
150  {
151  if(r->getValueIfAvailable(t,s,ds,ref))return true;
152  }
154  {
155  if(subset->getReferenceIfAvailable(dim,der,t,s,ds,ref))return true;
156  }
157  return false;
158  }
168  virtual double getUB(int dim, int der, double t,double s,double ds) const override
169  {
170  double value = unbound_;
171  for(ANominalConstraint* c:bound_[dim*N*2 + der*2 + 0])//walk through the own constraints
172  {
173  value = (std::min)(value,c->getValue(t,s,ds));
174  }
175  for(ANominalPlannerInformation* subset:subsets_)//query the subsets
176  {
177  value = (std::min)(value,subset->getUB(dim,der,t,s,ds));
178  }
179  return value;
180  }
190  virtual double getLB(int dim, int der, double t,double s,double ds) const override
191  {
192  double value = -unbound_;
193  for(ANominalConstraint* c:bound_[dim*N*2 + der*2 + 1])//walk through the own constraints
194  {
195  value = (std::max)(value,c->getValue(t,s,ds));
196  }
197  for(ANominalPlannerInformation* subset:subsets_)//query the subsets
198  {
199  value = (std::max)(value,subset->getLB(dim,der,t,s,ds));
200  }
201  return value;
202  }
209  virtual void update(double t0,double s0,double ds0) override
210  {
211  for(auto it=subsets_.begin();it!=subsets_.end();it++)(*it)->update(t0,s0,ds0);
212  for(int i=0;i<D*N;i++)for(auto it=ref_[i].begin();it!=ref_[i].end();it++)(*it)->update(t0,s0,ds0);
213  for(int i=0;i<D*N*2;i++)for(auto it=bound_[i].begin();it!=bound_[i].end();it++)(*it)->update(t0,s0,ds0);
214  }
215  };
216  }
217 }
Definition: anominalplanner.h:52
virtual ConstraintDirection getDirection()=0
@ UB
Definition: anominalplanner.h:56
Definition: anominalplannerinformation.h:27
virtual void update(double t0, double s0, double ds0)=0
update update all constraints and references
virtual double getLB(int dim, int der, double t, double s, double ds) const =0
getLB returns the lower bound for the offset's der's derivative in dimension dim
virtual double getUB(int dim, int der, double t, double s, double ds) const =0
getUB returns the upper bound for the offset's der's derivative in dimension dim
virtual bool getReferenceIfAvailable(int dim, int der, double t, double s, double ds, double &ref) const =0
getReferenceIfAvailable returns true if the reference for the dimension and derivative is available a...
Definition: anominalplanner.h:96
Definition: anominalplannerinformation.h:46
bool remove(ANominalConstraint *c)
Definition: anominalplannerinformation.h:83
virtual double getLB(int dim, int der, double t, double s, double ds) const override
Definition: anominalplannerinformation.h:190
void add(ANominalPlannerInformation *value)
Definition: anominalplannerinformation.h:118
TCset bound_[D *N *2]
Definition: anominalplannerinformation.h:51
void add(ANominalReference *r)
Definition: anominalplannerinformation.h:68
NominalPlannerInformationSet()
Definition: anominalplannerinformation.h:61
TRset ref_[D *N]
Definition: anominalplannerinformation.h:52
virtual void update(double t0, double s0, double ds0) override
Definition: anominalplannerinformation.h:209
std::vector< ANominalPlannerInformation * > TIset
Definition: anominalplannerinformation.h:50
virtual double getUB(int dim, int der, double t, double s, double ds) const override
Definition: anominalplannerinformation.h:168
bool remove(ANominalReference *r)
Definition: anominalplannerinformation.h:101
void add(ANominalConstraint *c)
Definition: anominalplannerinformation.h:75
std::vector< ANominalReference * > TRset
Definition: anominalplannerinformation.h:49
TIset subsets_
Definition: anominalplannerinformation.h:53
double unbound_
Definition: anominalplannerinformation.h:54
bool remove(ANominalPlannerInformation *value)
Definition: anominalplannerinformation.h:126
virtual bool getReferenceIfAvailable(int dim, int der, double t, double s, double ds, double &ref) const override
Definition: anominalplannerinformation.h:147
std::vector< ANominalConstraint * > TCset
Definition: anominalplannerinformation.h:48
T min(T a, T b, T c, T d)
Definition: adoremath.h:663
adoreMatrix< T, N, M > max(adoreMatrix< T, N, M > a, const adoreMatrix< T, N, M > &b)
Definition: adoremath.h:686
r
Definition: adore_suppress_lanechanges.py:209
Definition: areaofeffectconverter.h:20