ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
heading.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 <adore/mad/alfunction.h>
17 #include <algorithm>
18 
19 namespace adore
20 {
21  namespace mad
22  {
26  template<typename T>
27  class LHeading :public ALFunction<T, T>
28  {
29  private:
31  public:
32  typedef adoreMatrix<T, 2, 1> CTDF;
33  typedef T DT;
34  typedef T CT;
36  virtual ~LHeading() { delete m_df; }
37  virtual void setLimits(DT lo, DT hi)override
38  {
39  m_df->setLimits(lo, hi);
40  }
41  virtual DT limitHi() const override
42  {
43  return m_df->limitHi();
44  }
45  virtual DT limitLo() const override
46  {
47  return m_df->limitLo();
48  }
49  virtual CT f(DT x) const override
50  {
51  CTDF dy = m_df->f(x);
52  return (T)(std::atan2)(dy(1), dy(0));
53  }
54  virtual ALFunction<DT, CT>* clone()override
55  {
56  return new LHeading<T>((AScalarToN<T, 2>*)m_df->clone());
57  }
62  {
63  //compute curvature / derivative of heading:
64  // kappa = (ddY*dX - ddX*dY) / (dX�+dY�)
65  AScalarToN<T, 2>* df = m_df;
67 
68  auto result = funop::multiply<T, T, T, T>(
69  funop::add<T, T>(
70  funop::multiply<T, T, T, T>(
71  ddf->dimension(1)->clone(),
72  df->dimension(0)->clone()
73  ),
74  funop::minus<T, T, T, T>(
75  funop::multiply<T, T, T, T>(
76  ddf->dimension(0)->clone(),
77  df->dimension(1)->clone()
78  )
79  )
80  ),
81  funop::reciprocal<T>(
82  funop::add<T,T>(
83  funop::multiply<T, T, T, T>(
84  df->dimension(0)->clone(),
85  df->dimension(0)->clone()
86  ),
87  funop::multiply<T, T, T, T>(
88  df->dimension(1)->clone(),
89  df->dimension(1)->clone()
90  )
91  )
92  )
93  );
94  delete ddf;
95  return result;
96  }
97  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax)
98  {
99  CTDF ymin_tmp;
100  CTDF ymax_tmp;
101  m_df->bound(xmin, xmax, ymin_tmp, ymax_tmp);
102  interval<T> iy = adore::mad::atan2(interval<T>(ymin_tmp(1), ymax_tmp(1)), interval<T>(ymin_tmp(0), ymax_tmp(0)));
103  ymin = iy.lb;
104  ymax = iy.ub;
105  }
106  };
107 
108  namespace funop
109  {
113  template<typename T>
115  {
116  return new adore::mad::LHeading<T>(df);
117  }
118  }
119  }
120 }
Definition: alfunction.h:74
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax)=0
virtual ALFunction< DT, CT > * clone()=0
virtual CT f(DT x) const =0
virtual DT limitHi() const =0
virtual DT limitLo() const =0
virtual ALFunction< DT, CT > * create_derivative()=0
virtual void setLimits(DT lo, DT hi)=0
virtual SUBFUN * dimension(int i)=0
Definition: heading.h:28
virtual CT f(DT x) const override
Definition: heading.h:49
virtual void setLimits(DT lo, DT hi) override
Definition: heading.h:37
virtual ~LHeading()
Definition: heading.h:36
virtual DT limitHi() const override
Definition: heading.h:41
AScalarToN< T, 2 > * m_df
Definition: heading.h:30
virtual ALFunction< DT, CT > * clone() override
Definition: heading.h:54
virtual DT limitLo() const override
Definition: heading.h:45
T CT
Definition: heading.h:34
virtual ALFunction< DT, CT > * create_derivative() override
Definition: heading.h:61
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax)
Definition: heading.h:97
LHeading(AScalarToN< T, 2 > *df)
Definition: heading.h:35
adoreMatrix< T, 2, 1 > CTDF
Definition: heading.h:32
T DT
Definition: heading.h:33
ALFunction< T, T > * heading(AScalarToN< T, 2 > *df)
Definition: heading.h:114
interval< T > atan2(interval< T > y, interval< T > x)
Definition: intervalarithmetic.h:234
x
Definition: adore_set_goal.py:30
Definition: areaofeffectconverter.h:20
Definition: intervalarithmetic.h:30
T ub
Definition: intervalarithmetic.h:31
T lb
Definition: intervalarithmetic.h:31