FCL  0.6.0
Flexible Collision Library
gjk_solver_indep.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 
38 #ifndef FCL_NARROWPHASE_GJKSOLVERINDEP_H
39 #define FCL_NARROWPHASE_GJKSOLVERINDEP_H
40 
41 #include "fcl/common/deprecated.h"
42 #include "fcl/common/types.h"
43 #include "fcl/narrowphase/contact_point.h"
44 
45 namespace fcl
46 {
47 
48 namespace detail
49 {
50 
52 template <typename S_>
54 {
55  using S = S_;
56 
59  template<typename Shape1, typename Shape2>
60  FCL_DEPRECATED
61  bool shapeIntersect(
62  const Shape1& s1,
63  const Transform3<S>& tf1,
64  const Shape2& s2,
65  const Transform3<S>& tf2,
66  Vector3<S>* contact_points,
67  S* penetration_depth,
68  Vector3<S>* normal) const;
69 
71  template<typename Shape1, typename Shape2>
72  bool shapeIntersect(
73  const Shape1& s1,
74  const Transform3<S>& tf1,
75  const Shape2& s2,
76  const Transform3<S>& tf2,
77  std::vector<ContactPoint<S>>* contacts = nullptr) const;
78 
80  template<typename Shape>
82  const Shape& s,
83  const Transform3<S>& tf,
84  const Vector3<S>& P1,
85  const Vector3<S>& P2,
86  const Vector3<S>& P3,
87  Vector3<S>* contact_points = nullptr,
88  S* penetration_depth = nullptr,
89  Vector3<S>* normal = nullptr) const;
90 
92  template<typename Shape>
94  const Shape& s,
95  const Transform3<S>& tf1,
96  const Vector3<S>& P1,
97  const Vector3<S>& P2,
98  const Vector3<S>& P3,
99  const Transform3<S>& tf2,
100  Vector3<S>* contact_points = nullptr,
101  S* penetration_depth = nullptr,
102  Vector3<S>* normal = nullptr) const;
103 
105  template<typename Shape1, typename Shape2>
106  bool shapeDistance(
107  const Shape1& s1,
108  const Transform3<S>& tf1,
109  const Shape2& s2,
110  const Transform3<S>& tf2,
111  S* distance = nullptr,
112  Vector3<S>* p1 = nullptr,
113  Vector3<S>* p2 = nullptr) const;
114 
116  template<typename Shape>
118  const Shape& s,
119  const Transform3<S>& tf,
120  const Vector3<S>& P1,
121  const Vector3<S>& P2,
122  const Vector3<S>& P3,
123  S* distance = nullptr,
124  Vector3<S>* p1 = nullptr,
125  Vector3<S>* p2 = nullptr) const;
126 
128  template<typename Shape>
130  const Shape& s,
131  const Transform3<S>& tf1,
132  const Vector3<S>& P1,
133  const Vector3<S>& P2,
134  const Vector3<S>& P3,
135  const Transform3<S>& tf2,
136  S* distance = nullptr,
137  Vector3<S>* p1 = nullptr,
138  Vector3<S>* p2 = nullptr) const;
139 
141  GJKSolver_indep();
142 
143  void enableCachedGuess(bool if_enable) const;
144 
145  void setCachedGuess(const Vector3<S>& guess) const;
146 
147  Vector3<S> getCachedGuess() const;
148 
150  unsigned int epa_max_face_num;
151 
153  unsigned int epa_max_vertex_num;
154 
156  unsigned int epa_max_iterations;
157 
160 
163 
166 
168  mutable bool enable_cached_guess;
169 
171  mutable Vector3<S> cached_guess;
172 };
173 
176 
177 } // namespace detail
178 } // namespace fcl
179 
180 #include "fcl/narrowphase/detail/gjk_solver_indep-inl.h"
181 
182 #endif
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
Minimal contact information returned by collision.
Definition: contact_point.h:48
bool shapeTriangleDistance(const Shape &s, const Transform3< S > &tf, const Vector3< S > &P1, const Vector3< S > &P2, const Vector3< S > &P3, S *distance=nullptr, Vector3< S > *p1=nullptr, Vector3< S > *p2=nullptr) const
distance computation between one shape and a triangle
Definition: gjk_solver_indep-inl.h:792
Vector3< S > cached_guess
smart guess
Definition: gjk_solver_indep.h:171
S gjk_max_iterations
maximum number of iterations used for GJK iterations
Definition: gjk_solver_indep.h:165
bool shapeDistance(const Shape1 &s1, const Transform3< S > &tf1, const Shape2 &s2, const Transform3< S > &tf2, S *distance=nullptr, Vector3< S > *p1=nullptr, Vector3< S > *p2=nullptr) const
distance computation between two shapes
Definition: gjk_solver_indep-inl.h:627
S gjk_tolerance
the threshold used in GJK to stop iteration
Definition: gjk_solver_indep.h:162
GJKSolver_indep()
default setting for GJK algorithm
Definition: gjk_solver_indep-inl.h:920
bool enable_cached_guess
Whether smart guess can be provided.
Definition: gjk_solver_indep.h:168
unsigned int epa_max_iterations
maximum number of iterations used for EPA iterations
Definition: gjk_solver_indep.h:156
unsigned int epa_max_face_num
maximum number of simplex face used in EPA algorithm
Definition: gjk_solver_indep.h:150
unsigned int epa_max_vertex_num
maximum number of simplex vertex used in EPA algorithm
Definition: gjk_solver_indep.h:153
S distance(const Eigen::MatrixBase< DerivedA > &R0, const Eigen::MatrixBase< DerivedB > &T0, const kIOS< S > &b1, const kIOS< S > &b2, Vector3< S > *P, Vector3< S > *Q)
Approximate distance between two kIOS bounding volumes.
Definition: kIOS-inl.h:266
collision and distance solver based on GJK algorithm implemented in fcl (rewritten the code from the ...
Definition: gjk_solver_indep.h:53
S epa_tolerance
the threshold used in EPA to stop iteration
Definition: gjk_solver_indep.h:159
FCL_DEPRECATED bool shapeIntersect(const Shape1 &s1, const Transform3< S > &tf1, const Shape2 &s2, const Transform3< S > &tf2, Vector3< S > *contact_points, S *penetration_depth, Vector3< S > *normal) const
intersection checking between two shapes
bool shapeTriangleIntersect(const Shape &s, const Transform3< S > &tf, const Vector3< S > &P1, const Vector3< S > &P2, const Vector3< S > &P3, Vector3< S > *contact_points=nullptr, S *penetration_depth=nullptr, Vector3< S > *normal=nullptr) const
intersection checking between one shape and a triangle
Definition: gjk_solver_indep-inl.h:393