hpp-fcl  3.0.0
HPP fork of FCL -- The Flexible Collision Library
support_functions.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011-2014, Willow Garage, Inc.
5  * Copyright (c) 2014-2015, Open Source Robotics Foundation
6  * Copyright (c) 2021-2024, INRIA
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Open Source Robotics Foundation nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 
39 #ifndef HPP_FCL_SUPPORT_FUNCTIONS_H
40 #define HPP_FCL_SUPPORT_FUNCTIONS_H
41 
43 #include "hpp/fcl/math/transform.h"
44 #include "hpp/fcl/collision_data.h"
45 
46 namespace hpp {
47 namespace fcl {
48 
49 namespace details {
50 
62 };
63 
64 // ============================================================================
65 // ============================ SUPPORT FUNCTIONS =============================
66 // ============================================================================
77 template <int _SupportOptions = SupportOptions::NoSweptSphere>
78 Vec3f getSupport(const ShapeBase* shape, const Vec3f& dir, int& hint);
79 
82  // @brief Tracks which points have been visited in a ConvexBase.
83  std::vector<int8_t> visited;
84 
85  // @brief Tracks the last support direction used on this shape; used to
86  // warm-start the ConvexBase support function.
87  Vec3f last_dir = Vec3f::Zero();
88 
89  // @brief Temporary set used to compute the convex-hull of a support set.
90  // Only used for ConvexBase and Box.
92 };
93 
95 template <int _SupportOptions = SupportOptions::NoSweptSphere>
96 void getShapeSupport(const TriangleP* triangle, const Vec3f& dir,
97  Vec3f& support, int& /*unused*/,
98  ShapeSupportData& /*unused*/);
99 
101 template <int _SupportOptions = SupportOptions::NoSweptSphere>
102 void getShapeSupport(const Box* box, const Vec3f& dir, Vec3f& support,
103  int& /*unused*/, ShapeSupportData& /*unused*/);
104 
106 template <int _SupportOptions = SupportOptions::NoSweptSphere>
107 void getShapeSupport(const Sphere* sphere, const Vec3f& dir, Vec3f& support,
108  int& /*unused*/, ShapeSupportData& /*unused*/);
109 
111 template <int _SupportOptions = SupportOptions::NoSweptSphere>
112 void getShapeSupport(const Ellipsoid* ellipsoid, const Vec3f& dir,
113  Vec3f& support, int& /*unused*/,
114  ShapeSupportData& /*unused*/);
115 
117 template <int _SupportOptions = SupportOptions::NoSweptSphere>
118 void getShapeSupport(const Capsule* capsule, const Vec3f& dir, Vec3f& support,
119  int& /*unused*/, ShapeSupportData& /*unused*/);
120 
122 template <int _SupportOptions = SupportOptions::NoSweptSphere>
123 void getShapeSupport(const Cone* cone, const Vec3f& dir, Vec3f& support,
124  int& /*unused*/, ShapeSupportData& /*unused*/);
125 
127 template <int _SupportOptions = SupportOptions::NoSweptSphere>
128 void getShapeSupport(const Cylinder* cylinder, const Vec3f& dir, Vec3f& support,
129  int& /*unused*/, ShapeSupportData& /*unused*/);
130 
134 template <int _SupportOptions = SupportOptions::NoSweptSphere>
135 void getShapeSupport(const ConvexBase* convex, const Vec3f& dir, Vec3f& support,
136  int& hint, ShapeSupportData& /*unused*/);
137 
143 struct LargeConvex : ShapeBase {};
145 struct SmallConvex : ShapeBase {};
146 
148 template <int _SupportOptions = SupportOptions::NoSweptSphere>
149 void getShapeSupport(const SmallConvex* convex, const Vec3f& dir,
150  Vec3f& support, int& hint, ShapeSupportData& data);
151 
153 template <int _SupportOptions = SupportOptions::NoSweptSphere>
154 void getShapeSupport(const LargeConvex* convex, const Vec3f& dir,
155  Vec3f& support, int& hint, ShapeSupportData& support_data);
156 
157 // ============================================================================
158 // ========================== SUPPORT SET FUNCTIONS ===========================
159 // ============================================================================
195 template <int _SupportOptions = SupportOptions::NoSweptSphere>
196 void getSupportSet(const ShapeBase* shape, SupportSet& support_set, int& hint,
197  size_t num_sampled_supports = 6, FCL_REAL tol = 1e-3);
198 
206 template <int _SupportOptions = SupportOptions::NoSweptSphere>
207 void getSupportSet(const ShapeBase* shape, const Vec3f& dir,
208  SupportSet& support_set, int& hint,
209  size_t num_sampled_supports = 6, FCL_REAL tol = 1e-3) {
210  support_set.tf.rotation() = constructOrthonormalBasisFromVector(dir);
211  const Vec3f& support_dir = support_set.getNormal();
212  const Vec3f support = getSupport<_SupportOptions>(shape, support_dir, hint);
213  getSupportSet<_SupportOptions>(shape, support_set, hint, num_sampled_supports,
214  tol);
215 }
216 
219 template <int _SupportOptions = SupportOptions::NoSweptSphere>
220 void getShapeSupportSet(const TriangleP* triangle, SupportSet& support_set,
221  int& /*unused*/, ShapeSupportData& /*unused*/,
222  size_t /*unused*/ num_sampled_supports = 6,
223  FCL_REAL tol = 1e-3);
224 
227 template <int _SupportOptions = SupportOptions::NoSweptSphere>
228 void getShapeSupportSet(const Box* box, SupportSet& support_set,
229  int& /*unused*/, ShapeSupportData& support_data,
230  size_t /*unused*/ num_sampled_supports = 6,
231  FCL_REAL tol = 1e-3);
232 
235 template <int _SupportOptions = SupportOptions::NoSweptSphere>
236 void getShapeSupportSet(const Sphere* sphere, SupportSet& support_set,
237  int& /*unused*/, ShapeSupportData& /*unused*/,
238  size_t /*unused*/ num_sampled_supports = 6,
239  FCL_REAL /*unused*/ tol = 1e-3);
240 
243 template <int _SupportOptions = SupportOptions::NoSweptSphere>
244 void getShapeSupportSet(const Ellipsoid* ellipsoid, SupportSet& support_set,
245  int& /*unused*/, ShapeSupportData& /*unused*/,
246  size_t /*unused*/ num_sampled_supports = 6,
247  FCL_REAL /*unused*/ tol = 1e-3);
248 
251 template <int _SupportOptions = SupportOptions::NoSweptSphere>
252 void getShapeSupportSet(const Capsule* capsule, SupportSet& support_set,
253  int& /*unused*/, ShapeSupportData& /*unused*/,
254  size_t /*unused*/ num_sampled_supports = 6,
255  FCL_REAL tol = 1e-3);
256 
259 template <int _SupportOptions = SupportOptions::NoSweptSphere>
260 void getShapeSupportSet(const Cone* cone, SupportSet& support_set,
261  int& /*unused*/, ShapeSupportData& /*unused*/,
262  size_t num_sampled_supports = 6, FCL_REAL tol = 1e-3);
263 
266 template <int _SupportOptions = SupportOptions::NoSweptSphere>
267 void getShapeSupportSet(const Cylinder* cylinder, SupportSet& support_set,
268  int& /*unused*/, ShapeSupportData& /*unused*/,
269  size_t num_sampled_supports = 6, FCL_REAL tol = 1e-3);
270 
275 template <int _SupportOptions = SupportOptions::NoSweptSphere>
276 void getShapeSupportSet(const ConvexBase* convex, SupportSet& support_set,
277  int& hint, ShapeSupportData& support_data,
278  size_t /*unused*/ num_sampled_supports = 6,
279  FCL_REAL tol = 1e-3);
280 
283 template <int _SupportOptions = SupportOptions::NoSweptSphere>
284 void getShapeSupportSet(const SmallConvex* convex, SupportSet& support_set,
285  int& /*unused*/, ShapeSupportData& /*unused*/,
286  size_t /*unused*/ num_sampled_supports = 6,
287  FCL_REAL tol = 1e-3);
288 
291 template <int _SupportOptions = SupportOptions::NoSweptSphere>
292 void getShapeSupportSet(const LargeConvex* convex, SupportSet& support_set,
293  int& hint, ShapeSupportData& support_data,
294  size_t /*unused*/ num_sampled_supports = 6,
295  FCL_REAL tol = 1e-3);
296 
303  SupportSet::Polygon& cvx_hull);
304 
305 } // namespace details
306 
307 } // namespace fcl
308 } // namespace hpp
309 
310 #endif // HPP_FCL_SUPPORT_FUNCTIONS_H
Center at zero point, axis aligned box.
Definition: geometric_shapes.h:164
Capsule It is where is the distance between the point x and the capsule segment AB,...
Definition: geometric_shapes.h:381
Cone The base of the cone is at and the top is at .
Definition: geometric_shapes.h:465
Base for convex polytope.
Definition: geometric_shapes.h:638
Cylinder along Z axis. The cylinder is defined at its centroid.
Definition: geometric_shapes.h:555
Ellipsoid centered at point zero.
Definition: geometric_shapes.h:303
Base class for all basic geometric shapes.
Definition: geometric_shapes.h:59
Center at zero point sphere.
Definition: geometric_shapes.h:238
const Matrix3f & rotation() const
get rotation
Definition: transform.h:114
Triangle stores the points instead of only indices of points.
Definition: geometric_shapes.h:109
#define HPP_FCL_DLLAPI
Definition: config.hh:88
void getSupportSet(const ShapeBase *shape, SupportSet &support_set, int &hint, size_t num_sampled_supports=6, FCL_REAL tol=1e-3)
Computes the support set for shape. This function assumes the frame of the support set has already be...
void getShapeSupportSet(const TriangleP *triangle, SupportSet &support_set, int &, ShapeSupportData &, size_t num_sampled_supports=6, FCL_REAL tol=1e-3)
Triangle support set function. Assumes the support set frame has already been computed.
void getShapeSupport(const TriangleP *triangle, const Vec3f &dir, Vec3f &support, int &, ShapeSupportData &)
Triangle support function.
SupportOptions
Options for the computation of support points. NoSweptSphere option is used when the support function...
Definition: support_functions.h:59
@ NoSweptSphere
Definition: support_functions.h:60
@ WithSweptSphere
Definition: support_functions.h:61
void computeSupportSetConvexHull(SupportSet::Polygon &cloud, SupportSet::Polygon &cvx_hull)
Computes the convex-hull of support_set. For now, this function is only needed for Box and ConvexBase...
Vec3f getSupport(const ShapeBase *shape, const Vec3f &dir, int &hint)
the support function for shape. The output support point is expressed in the local frame of the shape...
Matrix3f constructOrthonormalBasisFromVector(const Vec3f &vec)
Construct othonormal basis from vector. The z-axis is the normalized input vector.
Definition: transform.h:261
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
double FCL_REAL
Definition: data_types.h:66
Main namespace.
Definition: broadphase_bruteforce.h:44
This structure allows to encode contact patches. A contact patch is defined by a set of points belong...
Definition: collision_data.h:512
Vec3f getNormal() const
Normal of the contact patch, expressed in the WORLD frame.
Definition: collision_data.h:569
Transform3f tf
Frame of the set, expressed in the world coordinates. The z-axis of the frame's rotation is the conta...
Definition: collision_data.h:518
std::vector< Vec2f > Polygon
Definition: collision_data.h:514
Cast a ConvexBase to a LargeConvex to use the log version of getShapeSupport. This is much faster tha...
Definition: support_functions.h:143
Stores temporary data for the computation of support points.
Definition: support_functions.h:81
SupportSet::Polygon polygon
Definition: support_functions.h:91
std::vector< int8_t > visited
Definition: support_functions.h:83
See LargeConvex.
Definition: support_functions.h:145