FCL  0.6.0
Flexible Collision Library
taylor_model.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011-2014, Willow Garage, Inc.
5  * Copyright (c) 2014-2016, Open Source Robotics Foundation
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Open Source Robotics Foundation nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 // This code is based on code developed by Stephane Redon at UNC and Inria for
37 // the CATCH library: http://graphics.ewha.ac.kr/CATCH/
38 
41 #ifndef FCL_CCD_TAYLOR_MODEL_H
42 #define FCL_CCD_TAYLOR_MODEL_H
43 
44 #include <memory>
45 #include <iostream>
46 #include "fcl/math/constants.h"
47 #include "fcl/math/motion/taylor_model/interval.h"
48 #include "fcl/math/motion/taylor_model/time_interval.h"
49 
50 namespace fcl
51 {
52 
57 template <typename S>
59 {
61  std::shared_ptr<TimeInterval<S>> time_interval_;
62 
64  S coeffs_[4];
65 
67  Interval<S> r_;
68 
69 public:
70 
71  void setTimeInterval(S l, S r);
72 
73  void setTimeInterval(const std::shared_ptr<TimeInterval<S>>& time_interval);
74 
75  const std::shared_ptr<TimeInterval<S>>& getTimeInterval() const;
76 
77  S coeff(std::size_t i) const;
78  S& coeff(std::size_t i);
79  const Interval<S>& remainder() const;
80  Interval<S>& remainder();
81 
82  TaylorModel();
83  TaylorModel(const std::shared_ptr<TimeInterval<S>>& time_interval);
84  TaylorModel(S coeff, const std::shared_ptr<TimeInterval<S>>& time_interval);
85  TaylorModel(S coeffs[3], const Interval<S>& r, const std::shared_ptr<TimeInterval<S>>& time_interval);
86  TaylorModel(S c0, S c1, S c2, S c3, const Interval<S>& r, const std::shared_ptr<TimeInterval<S>>& time_interval);
87 
88  TaylorModel operator + (const TaylorModel& other) const;
89  TaylorModel& operator += (const TaylorModel& other);
90 
91  TaylorModel operator - (const TaylorModel& other) const;
92  TaylorModel& operator -= (const TaylorModel& other);
93 
94  TaylorModel operator + (S d) const;
95  TaylorModel& operator += (S d);
96 
97  TaylorModel operator - (S d) const;
98  TaylorModel& operator -= (S d);
99 
100  TaylorModel operator * (const TaylorModel& other) const;
101  TaylorModel operator * (S d) const;
102  TaylorModel& operator *= (const TaylorModel& other);
103  TaylorModel& operator *= (S d);
104 
105  TaylorModel operator - () const;
106 
107  void print() const;
108 
109  Interval<S> getBound() const;
110  Interval<S> getBound(S l, S r) const;
111 
112  Interval<S> getTightBound() const;
113  Interval<S> getTightBound(S l, S r) const;
114 
115  Interval<S> getBound(S t) const;
116 
117  void setZero();
118 };
119 
120 template <typename S>
122 
123 template <typename S>
124 TaylorModel<S> operator + (S d, const TaylorModel<S>& a);
125 
126 template <typename S>
127 TaylorModel<S> operator - (S d, const TaylorModel<S>& a);
128 
130 template <typename S>
131 void generateTaylorModelForCosFunc(TaylorModel<S>& tm, S w, S q0);
132 
134 template <typename S>
135 void generateTaylorModelForSinFunc(TaylorModel<S>& tm, S w, S q0);
136 
138 template <typename S>
139 void generateTaylorModelForLinearFunc(TaylorModel<S>& tm, S p, S v);
140 
141 } // namespace fcl
142 
143 #include "fcl/math/motion/taylor_model/taylor_model-inl.h"
144 
145 #endif
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
Interval class for [a, b].
Definition: interval.h:50
TaylorModel operator*(const TaylorModel &other) const
Taylor model multiplication: f(t) = c0+c1*t+c2*t^2+c3*t^3+[a,b] g(t) = c0&#39;+c1&#39;*t+c2&#39;*t^2+c3&#39;*t^2+[c,d] f(t)g(t)= c0c0&#39;+ (c0c1&#39;+c1c0&#39;)t+ (c0c2&#39;+c1c1&#39;+c2c0&#39;)t^2+ (c0c3&#39;+c1c2&#39;+c2c1&#39;+c3c0&#39;)t^3+ [a,b][c,d]+ (c1c3&#39;+c2c2&#39;+c3c1&#39;)t^4+ (c2c3&#39;+c3c2&#39;)t^5+ (c3c3&#39;)t^6+ (c0+c1*t+c2*t^2+c3*t^3)[c,d]+ (c0&#39;+c1&#39;*t+c2&#39;*t^2+c3&#39;*c^3)[a,b].
Definition: taylor_model-inl.h:259
Definition: time_interval.h:50
TaylorModel implements a third order Taylor model, i.e., a cubic approximation of a function over a t...
Definition: taylor_model.h:58