param_func_dist.hpp
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_DIST_HPP
34 #define PARAM_FUNC_DIST_HPP
35 
36 #include <memory>
37 #include <vector>
38 #include <map>
39 #include <tuw_control/utils.h>
41 
42 namespace tuw
43 {
48 class ParamFuncsDist;
49 using ParamFuncsDistPtr = std::shared_ptr<ParamFuncsDist>;
50 using ParamFuncsDistConstPtr = std::shared_ptr<ParamFuncsDist const>;
51 
52 // enums
55 {
56  NONE,
57  V,
58  AV
59 };
60 
61 namespace
62 {
63 template <class TDerived>
64 struct ParamFuncsDistBaseCRTPTraits;
65 }
66 
67 template <typename TDerived>
69 {
70 protected:
71  using NumType = typename ParamFuncsDistBaseCRTPTraits<TDerived>::NumType;
72 
73  // special class member functions
74 public:
75  ParamFuncsDistBaseCRTP() = default;
76 
77 public:
78  ~ParamFuncsDistBaseCRTP() = default;
79 
80 public:
82 
83 public:
84  ParamFuncsDistBaseCRTP& operator=(const ParamFuncsDistBaseCRTP&) = default;
85 
86 public:
88 
89 public:
90  ParamFuncsDistBaseCRTP& operator=(ParamFuncsDistBaseCRTP&&) = delete;
91 
93 public:
94  void setDistCfMode(TraveledDistCfMode _distCfMode, const std::vector<std::size_t>& _distRelFuncIdx)
95  {
96  thisDerived().setDistCfModeImplCRTP(_distCfMode, _distRelFuncIdx);
97  }
99 public:
100  void setEvalDist(const NumType& _funcsDistEval, const EvalArcGuarantee& _eAG = EvalArcGuarantee::NONE)
101  {
102  thisDerived().setEvalDistImplCRTP(_funcsDistEval, _eAG);
103  }
106 public:
108  {
109  return thisDerived().computeSImplCRTP();
110  }
113 public:
115  {
116  return thisDerived().computeTImplCRTP(_s, _eAG);
117  }
122 public:
123  void computeS2TLattice(const std::vector<NumType>& _sLattice, std::vector<NumType>& _tLattice)
124  {
125  thisDerived().computeS2TLatticeImplCRTP(_sLattice, _tLattice);
126  }
136 public:
137  void computeS2TLattice(const NumType& _arc0, const NumType& _ds, std::vector<NumType>& _tLattice)
138  {
139  thisDerived().computeS2TLatticeImplCRTP(_arc0, _ds, _tLattice);
140  }
141 
142 private:
143  TDerived& thisDerived()
144  {
145  return static_cast<TDerived&>(*this);
146  }
147 
148 private:
149  const TDerived& thisDerived() const
150  {
151  return static_cast<const TDerived&>(*this);
152  }
153 };
154 
155 template <typename TNumType>
157 {
158  // special class member functions
159 public:
160  ParamFuncsDistBaseVirt() = default;
161 
162 public:
163  virtual ~ParamFuncsDistBaseVirt() = default;
164 
165 public:
167 
168 public:
169  ParamFuncsDistBaseVirt& operator=(const ParamFuncsDistBaseVirt&) = default;
170 
171 public:
173 
174 public:
175  ParamFuncsDistBaseVirt& operator=(ParamFuncsDistBaseVirt&&) = delete;
176 
178 public:
179  void setDistCfMode(TraveledDistCfMode _distCfMode, const std::vector<std::size_t>& _distRelFuncIdx)
180  {
181  setDistCfModeImplVirt(_distCfMode, _distRelFuncIdx);
182  }
184 public:
185  void setEvalDist(const TNumType& _funcsDistEval, const EvalArcGuarantee& _eAG = EvalArcGuarantee::NONE)
186  {
187  setEvalDistImplVirt(_funcsDistEval, _eAG);
188  }
191 public:
192  TNumType computeS() const
193  {
194  return computeSImplVirt();
195  }
198 public:
199  TNumType computeT(const TNumType& _s, const EvalArcGuarantee& _eAG = EvalArcGuarantee::NONE)
200  {
201  return computeTImplVirt(_s, _eAG);
202  }
207 public:
208  void computeS2TLattice(const std::vector<TNumType>& _sLattice, std::vector<TNumType>& _tLattice)
209  {
210  computeS2TLatticeImplVirt(_sLattice, _tLattice);
211  }
221 public:
222  void computeS2TLattice(const TNumType& _arc0, const TNumType& _ds, std::vector<TNumType>& _tLattice)
223  {
224  computeS2TLatticeImplVirt(_arc0, _ds, _tLattice);
225  }
226 
227  // pure virtual functions
228 private:
229  virtual void setDistCfModeImplVirt(TraveledDistCfMode _distCfMode,
230  const std::vector<std::size_t>& _distRelFuncIdx) = 0;
231 
232 private:
233  virtual void setEvalDistImplVirt(const TNumType& _funcsDistEval,
234  const EvalArcGuarantee& _evalArcGuarantee = EvalArcGuarantee::NONE) = 0;
235 
236 private:
237  virtual TNumType computeSImplVirt() const = 0;
238 
239 private:
240  virtual TNumType computeTImplVirt(const TNumType& _s,
241  const EvalArcGuarantee& _evalArcGuarantee = EvalArcGuarantee::NONE) = 0;
242 
243 private:
244  virtual void computeS2TLatticeImplVirt(const std::vector<TNumType>& _sLattice, std::vector<TNumType>& _tLattice) = 0;
245 
246 private:
247  virtual void computeS2TLatticeImplVirt(const TNumType& _arc0, const TNumType& _ds,
248  std::vector<TNumType>& _tLattice) = 0;
249 };
250 
251 template <typename TDerived, typename TNumType>
252 class ParamFuncsDistBase : public ParamFuncsDistBaseCRTP<ParamFuncsDistBase<TDerived, TNumType>>,
253  public ParamFuncsDistBaseVirt<TNumType>
254 {
255 public:
257 
258 public:
259  using NumType = TNumType;
260 
261  // special class member functions
262 public:
263  ParamFuncsDistBase() = default;
264 
265 public:
266  virtual ~ParamFuncsDistBase() = default;
267 
268 public:
269  ParamFuncsDistBase(const ParamFuncsDistBase&) = default;
270 
271 public:
272  ParamFuncsDistBase& operator=(const ParamFuncsDistBase&) = default;
273 
274 public:
276 
277 public:
278  ParamFuncsDistBase& operator=(ParamFuncsDistBase&&) = delete;
279 
280 public:
282 
283 public:
285 
286 public:
288 
289 public:
291 
292 public:
294 
295 private:
296  void setDistCfModeImplCRTP(TraveledDistCfMode _distCfMode, const std::vector<std::size_t>& _distRelFuncIdx)
297  {
298  thisDerived().setDistCfModeImpl(_distCfMode, _distRelFuncIdx);
299  }
300 
301 private:
302  void setEvalDistImplCRTP(const TNumType& _funcsDistEval, const EvalArcGuarantee& _eAG)
303  {
304  thisDerived().setEvalDistImpl(_funcsDistEval, _eAG);
305  }
306 
307 private:
308  TNumType computeSImplCRTP() const
309  {
310  return thisDerived().computeSImpl();
311  }
312 
313 private:
314  TNumType computeTImplCRTP(const TNumType& _s, const EvalArcGuarantee& _eAG)
315  {
316  return thisDerived().computeTImpl(_s, _eAG);
317  }
318 
319 private:
320  void computeS2TLatticeImplCRTP(const std::vector<TNumType>& _sLattice, std::vector<TNumType>& _tLattice)
321  {
322  thisDerived().computeS2TLatticeImpl(_sLattice, _tLattice);
323  }
324 
325 private:
326  void computeS2TLatticeImplCRTP(const TNumType& _arc0, const TNumType& _ds, std::vector<TNumType>& _tLattice)
327  {
328  thisDerived().computeS2TLatticeImpl(_arc0, _ds, _tLattice);
329  }
330 
331 private:
332  virtual void setDistCfModeImplVirt(TraveledDistCfMode _distCfMode,
333  const std::vector<std::size_t>& _distRelFuncIdx) override final
334  {
335  thisDerived().setDistCfModeImpl(_distCfMode, _distRelFuncIdx);
336  }
337 
338 private:
339  virtual void setEvalDistImplVirt(const TNumType& _funcsDistEval, const EvalArcGuarantee& _eAG) override final
340  {
341  thisDerived().setEvalDistImpl(_funcsDistEval, _eAG);
342  }
343 
344 private:
345  virtual TNumType computeSImplVirt() const override final
346  {
347  return thisDerived().computeSImpl();
348  }
349 
350 private:
351  virtual TNumType computeTImplVirt(const TNumType& _s, const EvalArcGuarantee& _eAG) override final
352  {
353  return thisDerived().computeTImpl(_s, _eAG);
354  }
355 
356 private:
357  virtual void computeS2TLatticeImplVirt(const std::vector<TNumType>& _sLattice,
358  std::vector<TNumType>& _tLattice) override final
359  {
360  thisDerived().computeS2TLatticeImpl(_sLattice, _tLattice);
361  }
362 
363 private:
364  virtual void computeS2TLatticeImplVirt(const TNumType& _arc0, const TNumType& _ds,
365  std::vector<TNumType>& _tLattice) override final
366  {
367  thisDerived().computeS2TLatticeImpl(_arc0, _ds, _tLattice);
368  }
369 
370 private:
371  TDerived& thisDerived()
372  {
373  return static_cast<TDerived&>(*this);
374  }
375 
376 private:
377  const TDerived& thisDerived() const
378  {
379  return static_cast<const TDerived&>(*this);
380  }
381 
382  template <typename TDerived2>
384  template <typename TNum2>
386 };
387 
388 namespace
389 {
390 template <typename TDerived, typename TNumType>
391 struct ParamFuncsDistBaseCRTPTraits<ParamFuncsDistBase<TDerived, TNumType>>
392 {
393  using NumType = TNumType;
394 };
395 
396 } // namespace <anonymous>
397 }
398 
399 #endif // PARAM_FUNC_DIST_HPP
TNumType computeT(const TNumType &_s, const EvalArcGuarantee &_eAG=EvalArcGuarantee::NONE)
void computeS2TLattice(const TNumType &_arc0, const TNumType &_ds, std::vector< TNumType > &_tLattice)
Computes arc parametrization lattice given an inital arc and distance parametrized sampling interval...
const TDerived & thisDerived() const
virtual TNumType computeTImplVirt(const TNumType &_s, const EvalArcGuarantee &_eAG) overridefinal
void setEvalDistImplCRTP(const TNumType &_funcsDistEval, const EvalArcGuarantee &_eAG)
void computeS2TLattice(const std::vector< TNumType > &_sLattice, std::vector< TNumType > &_tLattice)
Computes arc parametrization lattice given a distance-parametrized lattice.
void setDistCfModeImplCRTP(TraveledDistCfMode _distCfMode, const std::vector< std::size_t > &_distRelFuncIdx)
virtual void setDistCfModeImplVirt(TraveledDistCfMode _distCfMode, const std::vector< std::size_t > &_distRelFuncIdx) overridefinal
virtual void computeS2TLatticeImplVirt(const TNumType &_arc0, const TNumType &_ds, std::vector< TNumType > &_tLattice) overridefinal
typename ParamFuncsDistBaseCRTPTraits< ParamFuncsDistBase< ParamFuncsSpline0Dist< TNumType, TFuncSize, TArcLatticeSize >, TNumType > >::NumType NumType
void computeS2TLatticeImplCRTP(const std::vector< TNumType > &_sLattice, std::vector< TNumType > &_tLattice)
void computeS2TLattice(const std::vector< NumType > &_sLattice, std::vector< NumType > &_tLattice)
Computes arc parametrization lattice given a distance-parametrized lattice.
std::shared_ptr< ParamFuncsDist const > ParamFuncsDistConstPtr
agent base center linear velocity is parametric function
virtual TNumType computeSImplVirt() const overridefinal
virtual void computeS2TLatticeImplVirt(const std::vector< TNumType > &_sLattice, std::vector< TNumType > &_tLattice) overridefinal
agent base center linear acceleration is parametric function
void computeS2TLattice(const NumType &_arc0, const NumType &_ds, std::vector< NumType > &_tLattice)
Computes arc parametrization lattice given an inital arc and distance parametrized sampling interval...
void setDistCfMode(TraveledDistCfMode _distCfMode, const std::vector< std::size_t > &_distRelFuncIdx)
Initializer of the Closed form distance computation mode.
TNumType computeTImplCRTP(const TNumType &_s, const EvalArcGuarantee &_eAG)
EvalArcGuarantee
Flags if any guarantees about evaluation arc relative to last evaluation arc are present.
Definition: param_func.hpp:61
void setEvalDist(const NumType &_funcsDistEval, const EvalArcGuarantee &_eAG=EvalArcGuarantee::NONE)
Moves to evaluation arc at which the traveled distance _funcsDistEval is achieved.
TNumType computeSImplCRTP() const
void setDistCfMode(TraveledDistCfMode _distCfMode, const std::vector< std::size_t > &_distRelFuncIdx)
Initializer of the Closed form distance computation mode.
no closed-form distance computation mode
const TDerived & thisDerived() const
void setEvalDist(const TNumType &_funcsDistEval, const EvalArcGuarantee &_eAG=EvalArcGuarantee::NONE)
Moves to evaluation arc at which the traveled distance _funcsDistEval is achieved.
virtual void setEvalDistImplVirt(const TNumType &_funcsDistEval, const EvalArcGuarantee &_eAG) overridefinal
std::shared_ptr< ParamFuncsDist > ParamFuncsDistPtr
NumType computeT(const NumType &_s, const EvalArcGuarantee &_eAG=EvalArcGuarantee::NONE)
TraveledDistCfMode
Required type of traveled distance computation relative to the parametric function.
void computeS2TLatticeImplCRTP(const TNumType &_arc0, const TNumType &_ds, std::vector< TNumType > &_tLattice)


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