param_func_spline0_dist.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Software License Agreement (BSD License) *
3  * Copyright (C) 2016 by Horatiu George Todoran <todorangrg@gmail.com> *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions *
7  * are met: *
8  * *
9  * 1. Redistributions of source code must retain the above copyright *
10  * notice, this list of conditions and the following disclaimer. *
11  * 2. Redistributions in binary form must reproduce the above copyright *
12  * notice, this list of conditions and the following disclaimer in *
13  * the documentation and/or other materials provided with the *
14  * distribution. *
15  * 3. Neither the name of the copyright holder nor the names of its *
16  * contributors may be used to endorse or promote products derived *
17  * from this software without specific prior written permission. *
18  * *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY *
29  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
30  * POSSIBILITY OF SUCH DAMAGE. *
31  ***************************************************************************/
32 
33 #ifndef PARAM_FUNC_SPLINE0_DIST_H
34 #define PARAM_FUNC_SPLINE0_DIST_H
35 
36 #include <memory>
37 #include <vector>
38 
40 
41 namespace tuw
42 {
50 class ParamFuncsSpline0Dist;
51 using ParamFuncsSpline0DistPtr = std::shared_ptr<ParamFuncsSpline0Dist>;
52 using ParamFuncsSpline0DistConstPtr = std::shared_ptr<ParamFuncsSpline0Dist const>;
54 {
55  //--------------------------------------- ParamFunc implementation ---------------------------------------//
58 protected:
60  {
61  FuncCacheData(const FuncCtrlPt& _ctrlPt) : val(_ctrlPt.val), arc(_ctrlPt.arc)
62  {
63  }
64  const double& val;
65  const double& arc;
66  std::array<double, nrModesMax_> cache;
67  };
68 
69  // special class member functions
70 public:
71  ParamFuncsSpline0Dist() = default;
72 
73 public:
74  virtual ~ParamFuncsSpline0Dist() = default;
75 
76 public:
77  ParamFuncsSpline0Dist(const ParamFuncsSpline0Dist&); // = default;
78 public:
80 public:
82 
83 public:
85 
86  //(re-)implemented virtual functions
87 protected:
88  virtual void initImpl() override;
90 public:
91  virtual void precompute() override;
92 
93 public:
94  void setEvalArc(const double& _funcsArcEval,
95  const EvalArcGuarantee& _evalArcGuarantee = EvalArcGuarantee::NONE) override;
96 
97 public:
98  virtual double computeFuncVal(const std::size_t& _funcIdx) const override;
99 
100 public:
101  virtual double computeFuncDiff1(const std::size_t& _funcIdx) const override;
102 
103 public:
104  virtual double computeFuncDiff2(const std::size_t& _funcIdx) const override;
105 
106 public:
107  virtual double computeFuncInt1(const std::size_t& _funcIdx) const override;
108 
109 public:
110  virtual double computeFuncInt2(const std::size_t& _funcIdx) const override;
111 
114 private:
115  double computeFuncDeltaInt1(const std::size_t& _funcIdx, const double& _arcEnd) const;
118 private:
119  double computeFuncDeltaInt2(const std::size_t& _funcIdx, const double& _arcEnd) const;
120 
123 protected:
124  std::vector<std::size_t> funcEvalArcCacheIdxUnder_;
126 protected:
127  std::vector<std::vector<FuncCacheData> > funcEvalCache_;
129 private:
130  std::vector<std::vector<std::size_t> > arc2func_;
131 
132  //--------------------------------------- ParamFuncDist implementation ---------------------------------------//
133 
134  //(re-)implemented virtual functions
135 public:
136  void setDistCfMode(TraveledDistCfMode _distCfMode, const std::vector<std::size_t>& _distRelFuncIdx) override;
137 
138 public:
139  double computeS() const override;
140 
141 public:
142  double computeT(const double& _s, const EvalArcGuarantee& _evalArcGuarantee = EvalArcGuarantee::NONE) override;
143 
144 public:
145  void setEvalDist(const double& _funcsDistEval,
146  const EvalArcGuarantee& _evalArcGuarantee = EvalArcGuarantee::NONE) override;
147 
148 public:
149  void computeS2TLattice(const std::vector<double>& _sLattice, std::vector<double>& _tLattice) override;
150 
151 public:
152  void computeS2TLattice(const double& _arc0, const double& _ds, std::vector<double>& _tLattice) override;
153 
156 public:
157  static double computeDeltaS_V_AV(const double& _dt, const double& _v0, const double& _av);
160 public:
161  static double computeDeltaT_V_AV(const double& _ds, const double& _v0, const double& _av);
162 
164 private:
165  void precomputeDist();
167 private:
168  double computeTImpl(const double& _s, const EvalArcGuarantee& _evalArcGuarantee);
170 private:
171  double computeS_V() const;
173 private:
174  double computeS_AV() const;
177 private:
178  double computeT_V(const double& _ds) const;
181 private:
182  double computeT_AV(const double& _ds) const;
183 
185 private:
186  std::vector<std::size_t> distLinkedFuncIdx_;
188 private:
189  std::vector<double> distEvalCache_;
191 private:
194 private:
195  std::vector<std::size_t> distRelFuncIdx_;
197 private:
198  std::size_t distLinkedArcIdx_;
199 
200 private:
201  using ComputeSFuncPtr = double (ParamFuncsSpline0Dist::*)() const;
202 
203 private:
204  using ComputeDs2DtPtr = double (ParamFuncsSpline0Dist::*)(const double&) const;
205 
206 private:
208 
209 private:
211 };
212 }
213 
214 #endif // PARAM_FUNC_SPLINE0_DIST_H
virtual double computeFuncInt2(const std::size_t &_funcIdx) const override
Computes double integral of parametric function with index _funcIdx on interval [funcsArcBegin_, funcsArcEnd_].
TraveledDistCfMode distCfMode_
Closed form distance computation mode.
std::vector< std::vector< std::size_t > > arc2func_
Maps the arc parametrizations to the functions that use them.
void setDistCfMode(TraveledDistCfMode _distCfMode, const std::vector< std::size_t > &_distRelFuncIdx) override
double(ParamFuncsSpline0Dist::*)() const ComputeSFuncPtr
std::vector< std::size_t > distLinkedFuncIdx_
Indexes of parametric functions used for computing the traveled distance.
virtual double computeFuncDiff2(const std::size_t &_funcIdx) const override
Computes 2nd derivative of parametric function with index _funcIdx at parametric arc set by setEvalAr...
double computeFuncDeltaInt1(const std::size_t &_funcIdx, const double &_arcEnd) const
Computes the integral of the parametric function _ on interval [funcEvalArcCacheIdxOld_[func2Arc_[_fu...
virtual void initImpl() override
Called at end of init. To be used by extended classes.
std::vector< double > distEvalCache_
Cached values of traveled distance computation.
std::array< double, nrModesMax_ > cache
std::size_t distLinkedArcIdx_
Index of the parametrized function that relates to distance computation.
double computeT(const double &_s, const EvalArcGuarantee &_evalArcGuarantee=EvalArcGuarantee::NONE) override
double computeS_AV() const
Computes distance on a piecewise linear function describing the center linear acceleration.
double computeT_V(const double &_ds) const
Computes arc parametrization on a piecewise linear function describing the center linear velocity at ...
ParamFuncsSpline0Dist & operator=(const ParamFuncsSpline0Dist &)
EvalArcGuarantee
Flags if any guarantees about evaluation arc relative to last evaluation arc are present.
Definition: param_func.h:80
Control point variable.
Definition: param_func.h:115
virtual ~ParamFuncsSpline0Dist()=default
virtual double computeFuncInt1(const std::size_t &_funcIdx) const override
Computes integral of parametric function with index _funcIdx on interval [funcsArcBegin_, funcsArcEnd_].
double(ParamFuncsSpline0Dist::*)(const double &) const ComputeDs2DtPtr
virtual void precompute() override
Precomputes cached data. To be called after ANY control point modifications.
Structure referencing a control point and storing cached relevant function evaluation data (derivativ...
std::vector< std::vector< FuncCacheData > > funcEvalCache_
Cached values of the used function evaluation modes.
void setEvalArc(const double &_funcsArcEval, const EvalArcGuarantee &_evalArcGuarantee=EvalArcGuarantee::NONE) override
Sets parametric function evaluation arc.
double computeFuncDeltaInt2(const std::size_t &_funcIdx, const double &_arcEnd) const
Computes the double integral integral of the parametric function _ on interval [funcEvalArcCacheIdxOl...
static double computeDeltaT_V_AV(const double &_ds, const double &_v0, const double &_av)
Helper function that computes deltaT (from the evalArc_ position) operating on one function control p...
Extends manipulation of parametric functions collection with closed-form arc length (distance) comput...
std::vector< std::size_t > funcEvalArcCacheIdxUnder_
Contains the index of the <u>next</u> control point relative to the last evaluation point...
std::shared_ptr< ParamFuncsSpline0Dist > ParamFuncsSpline0DistPtr
void setEvalDist(const double &_funcsDistEval, const EvalArcGuarantee &_evalArcGuarantee=EvalArcGuarantee::NONE) override
Moves to evaluation arc at which the traveled distance _funcsDistEval is achieved.
virtual double computeFuncDiff1(const std::size_t &_funcIdx) const override
Computes 1st derivative of parametric function with index _funcIdx at parametric arc set by setEvalAr...
std::shared_ptr< ParamFuncsSpline0Dist const > ParamFuncsSpline0DistConstPtr
virtual double computeFuncVal(const std::size_t &_funcIdx) const override
Computes value of parametric function with index _funcIdx at parametric arc set by setEvalArc...
static double computeDeltaS_V_AV(const double &_dt, const double &_v0, const double &_av)
Helper function that computes deltaS (from the evalArc_ position) operating on one function control p...
void precomputeDist()
Precomputes distance invervals.
double computeS_V() const
Computes distance on a piecewise linear function describing the center linear velocity.
double computeTImpl(const double &_s, const EvalArcGuarantee &_evalArcGuarantee)
Internal implementation of computing the arc parametrization given a distance _s. ...
double computeT_AV(const double &_ds) const
Computes arc parametrization on a piecewise linear function describing the center linear acceleration...
std::vector< std::size_t > distRelFuncIdx_
TraveledDistCfMode
Required type of traveled distance computation relative to the parametric function.
void computeS2TLattice(const std::vector< double > &_sLattice, std::vector< double > &_tLattice) override
Computes arc parametrization lattice given a distance-parametrized lattice.


tuw_control
Author(s): George Todoran
autogenerated on Mon Jun 10 2019 15:27:21