ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
truedistancepath.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 <math.h>
18 
19 namespace adore
20 {
21  namespace mad
22  {
31  template<typename T, int N>
32  adoreMatrix<T, 1, 0>& path_distance(ALFunction<T, adoreMatrix<T, N, 1>>* path, const adoreMatrix<T, 1, 0>& x)
33  {
34  adoreMatrix<T, 1, 0> d;
35  d = dlib::zeros_matrix<T>(1, x.nc());
37  for (int i = 1; i < x.nc(); i++)
38  {
39  adoreMatrix<T, N, 1> vi = v->f(x(i - 1));
40  T n = 0;
41  for (int j = 0; j < N; j++)
42  {
43  T nj = vi(j);
44  n += nj*nj;
45  }
46  d(i) = d(i - 1) + sqrt(n);
47  }
48  delete v;
49  return d;
50  }
51 
61  template<typename T, int N>
62  ALFunction<T, adoreMatrix<T, 2, 1>>* create_trueDistancePath(ALFunction<T, adoreMatrix<T, N, 1>>* path, int count)
63  {
64  adoreMatrix<T, 1, 0> x;
65  adoreMatrix<T, 1, 0> y;
66  x = adore::linspace<T>(path->limitLo(), path->limitHi(), count);
67  y = path_distance(path, x);
68  return funop::chain(path->clone(), new LLinearPiecewiseFunctionS<T>(y, x));
69  }
70  }
71 }
Definition: alfunction.h:74
virtual CT f(DT x) const =0
virtual ALFunction< DT, CT > * create_derivative()=0
Definition: llinearpiecewisefunction.h:32
ALFunction< DTb, CTa > * chain(ALFunction< DTa, CTa > *a, ALFunction< DTb, DTa > *b)
Definition: alfunction.h:778
adoreMatrix< T, 1, 0 > & path_distance(ALFunction< T, adoreMatrix< T, N, 1 >> *path, const adoreMatrix< T, 1, 0 > &x)
Definition: truedistancepath.h:32
ALFunction< T, adoreMatrix< T, 2, 1 > > * create_trueDistancePath(ALFunction< T, adoreMatrix< T, N, 1 >> *path, int count)
Definition: truedistancepath.h:62
x
Definition: adore_set_goal.py:30
y
Definition: adore_set_goal.py:31
Definition: areaofeffectconverter.h:20