ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
tunnelprojection.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 
18 namespace adore
19 {
20  namespace mad
21  {
31  template <typename T,int dtun_center,int dtun_left,int dtun_right,int dfin>
36  T winput,
37  int ixtun=1,int iytun=2,int idleft=1,int idright=1,int ixin=1,int iyin=2)
38  {
39  adoreMatrix<T> resultmat;
40  resultmat.set_size(5,finput->getData().nc());
41 
42  T w2 = winput/(T)2;
43  T n=(T)0;
44  T s = tunnel_center->getClosestParameter( finput->getData()(ixin,0),finput->getData()(iyin,0),ixtun,iytun,n);
45  T dleft = tunnel_left->fi(s,idleft-1);
46  T dright = tunnel_right->fi(s,idright-1);
47  resultmat(0,0) = finput->getData()(0,0);
48  resultmat(1,0) = s;
49  resultmat(2,0) = adore::mad::overlaps(dright,dleft,n-w2,n+w2)?(T)1:(T)0;
50  resultmat(3,0) = (n+w2)/(n+w2>(T)0?dleft:dright);
51  resultmat(4,0) = (n-w2)/(n-w2>(T)0?dleft:dright);
52 
53  for(int i=1;i<finput->getData().nc();i++)
54  {
55  s = tunnel_center->getClosestParameter_local(finput->getData()(ixin,i),finput->getData()(iyin,i),ixtun,iytun,s,&n);
56  dleft = tunnel_left->fi(s,idleft-1);
57  dright = tunnel_right->fi(s,idright-1);
58  resultmat(0,i) = finput->getData()(0,i);
59  resultmat(1,i) = s;
60  resultmat(2,i) = adore::mad::overlaps(dright,dleft,n-w2,n+w2)?(T)1:(T)0;
61  resultmat(3,i) = (n+w2)/(n+w2>(T)0?dleft:dright);
62  resultmat(4,i) = (n-w2)/(n-w2>(T)0?dleft:dright);
63  }
64 
65  return LLinearPiecewiseFunctionM<T,4>(resultmat);
66  }
67  }
68 }
Definition: llinearpiecewisefunction.h:139
double getClosestParameter_local(T px, T py, int d1, int d2, T x0, T *n_min=nullptr) const
Definition: llinearpiecewisefunction.h:1034
double getClosestParameter(T px, T py, int d1, int d2, T &n_min) const
Definition: llinearpiecewisefunction.h:1014
virtual T fi(DT x, int row) const override
Definition: llinearpiecewisefunction.h:391
adoreMatrix< T, n+1, 0 > & getData()
Definition: llinearpiecewisefunction.h:147
LLinearPiecewiseFunctionM< T, 4 > getTunnelProjection(LLinearPiecewiseFunctionM< T, dtun_center > *tunnel_center, LLinearPiecewiseFunctionM< T, dtun_left > *tunnel_left, LLinearPiecewiseFunctionM< T, dtun_right > *tunnel_right, LLinearPiecewiseFunctionM< T, dfin > *finput, T winput, int ixtun=1, int iytun=2, int idleft=1, int idright=1, int ixin=1, int iyin=2)
Definition: tunnelprojection.h:32
bool overlaps(const T &a0, const T &a1, const T &b0, const T &b1)
Definition: adoremath.h:655
Definition: areaofeffectconverter.h:20