coal 3.0.1
Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library
Loading...
Searching...
No Matches
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 COAL_SUPPORT_FUNCTIONS_H
40#define COAL_SUPPORT_FUNCTIONS_H
41
43#include "coal/math/transform.h"
44#include "coal/collision_data.h"
46
47namespace coal {
48namespace details {
49
50// ============================================================================
51// ============================ SUPPORT FUNCTIONS =============================
52// ============================================================================
63template <int _SupportOptions = SupportOptions::NoSweptSphere>
64Vec3s getSupport(const ShapeBase* shape, const Vec3s& dir, int& hint);
65
67template <int _SupportOptions = SupportOptions::NoSweptSphere>
68void getShapeSupport(const TriangleP* triangle, const Vec3s& dir,
69 Vec3s& support, int& /*unused*/,
70 ShapeSupportData& /*unused*/);
71
73template <int _SupportOptions = SupportOptions::NoSweptSphere>
74void getShapeSupport(const Box* box, const Vec3s& dir, Vec3s& support,
75 int& /*unused*/, ShapeSupportData& /*unused*/);
76
78template <int _SupportOptions = SupportOptions::NoSweptSphere>
79void getShapeSupport(const Sphere* sphere, const Vec3s& dir, Vec3s& support,
80 int& /*unused*/, ShapeSupportData& /*unused*/);
81
83template <int _SupportOptions = SupportOptions::NoSweptSphere>
84void getShapeSupport(const Ellipsoid* ellipsoid, const Vec3s& dir,
85 Vec3s& support, int& /*unused*/,
86 ShapeSupportData& /*unused*/);
87
89template <int _SupportOptions = SupportOptions::NoSweptSphere>
90void getShapeSupport(const Capsule* capsule, const Vec3s& dir, Vec3s& support,
91 int& /*unused*/, ShapeSupportData& /*unused*/);
92
94template <int _SupportOptions = SupportOptions::NoSweptSphere>
95void getShapeSupport(const Cone* cone, const Vec3s& dir, Vec3s& support,
96 int& /*unused*/, ShapeSupportData& /*unused*/);
97
99template <int _SupportOptions = SupportOptions::NoSweptSphere>
100void getShapeSupport(const Cylinder* cylinder, const Vec3s& dir, Vec3s& support,
101 int& /*unused*/, ShapeSupportData& /*unused*/);
102
106template <int _SupportOptions = SupportOptions::NoSweptSphere,
107 typename IndexType>
108void getShapeSupport(const ConvexBaseTpl<IndexType>* convex, const Vec3s& dir,
109 Vec3s& support, int& hint, ShapeSupportData& /*unused*/);
110
116template <typename IndexType>
117struct LargeConvex : ConvexBaseTpl<IndexType> {};
120
122template <typename IndexType>
123struct SmallConvex : ConvexBaseTpl<IndexType> {};
126
128template <int _SupportOptions = SupportOptions::NoSweptSphere,
129 typename IndexType>
130void getShapeSupport(const SmallConvex<IndexType>* convex, const Vec3s& dir,
131 Vec3s& support, int& hint, ShapeSupportData& data);
132
134template <int _SupportOptions = SupportOptions::NoSweptSphere,
135 typename IndexType>
136void getShapeSupport(const LargeConvex<IndexType>* convex, const Vec3s& dir,
137 Vec3s& support, int& hint, ShapeSupportData& support_data);
138
139// ============================================================================
140// ========================== SUPPORT SET FUNCTIONS ===========================
141// ============================================================================
177template <int _SupportOptions = SupportOptions::NoSweptSphere>
178void getSupportSet(const ShapeBase* shape, SupportSet& support_set, int& hint,
179 size_t num_sampled_supports = 6, Scalar tol = Scalar(1e-3));
180
188template <int _SupportOptions = SupportOptions::NoSweptSphere>
189void getSupportSet(const ShapeBase* shape, const Vec3s& dir,
190 SupportSet& support_set, int& hint,
191 size_t num_sampled_supports = 6, Scalar tol = Scalar(1e-3)) {
193 const Vec3s& support_dir = support_set.getNormal();
194 const Vec3s support = getSupport<_SupportOptions>(shape, support_dir, hint);
195 getSupportSet<_SupportOptions>(shape, support_set, hint, num_sampled_supports,
196 tol);
197}
198
201template <int _SupportOptions = SupportOptions::NoSweptSphere>
202void getShapeSupportSet(const TriangleP* triangle, SupportSet& support_set,
203 int& /*unused*/, ShapeSupportData& /*unused*/,
204 size_t /*unused*/ num_sampled_supports = 6,
205 Scalar tol = Scalar(1e-3));
206
209template <int _SupportOptions = SupportOptions::NoSweptSphere>
210void getShapeSupportSet(const Box* box, SupportSet& support_set,
211 int& /*unused*/, ShapeSupportData& support_data,
212 size_t /*unused*/ num_sampled_supports = 6,
213 Scalar tol = Scalar(1e-3));
214
217template <int _SupportOptions = SupportOptions::NoSweptSphere>
218void getShapeSupportSet(const Sphere* sphere, SupportSet& support_set,
219 int& /*unused*/, ShapeSupportData& /*unused*/,
220 size_t /*unused*/ num_sampled_supports = 6,
221 Scalar /*unused*/ tol = Scalar(1e-3));
222
225template <int _SupportOptions = SupportOptions::NoSweptSphere>
226void getShapeSupportSet(const Ellipsoid* ellipsoid, SupportSet& support_set,
227 int& /*unused*/, ShapeSupportData& /*unused*/,
228 size_t /*unused*/ num_sampled_supports = 6,
229 Scalar /*unused*/ tol = Scalar(1e-3));
230
233template <int _SupportOptions = SupportOptions::NoSweptSphere>
234void getShapeSupportSet(const Capsule* capsule, SupportSet& support_set,
235 int& /*unused*/, ShapeSupportData& /*unused*/,
236 size_t /*unused*/ num_sampled_supports = 6,
237 Scalar tol = Scalar(1e-3));
238
241template <int _SupportOptions = SupportOptions::NoSweptSphere>
242void getShapeSupportSet(const Cone* cone, SupportSet& support_set,
243 int& /*unused*/, ShapeSupportData& /*unused*/,
244 size_t num_sampled_supports = 6,
245 Scalar tol = Scalar(1e-3));
246
249template <int _SupportOptions = SupportOptions::NoSweptSphere>
250void getShapeSupportSet(const Cylinder* cylinder, SupportSet& support_set,
251 int& /*unused*/, ShapeSupportData& /*unused*/,
252 size_t num_sampled_supports = 6,
253 Scalar tol = Scalar(1e-3));
254
259template <int _SupportOptions = SupportOptions::NoSweptSphere,
260 typename IndexType>
262 SupportSet& support_set, int& hint,
263 ShapeSupportData& support_data,
264 size_t /*unused*/ num_sampled_supports = 6,
265 Scalar tol = Scalar(1e-3));
266
269template <int _SupportOptions = SupportOptions::NoSweptSphere,
270 typename IndexType>
272 SupportSet& support_set, int& /*unused*/,
273 ShapeSupportData& /*unused*/,
274 size_t /*unused*/ num_sampled_supports = 6,
275 Scalar tol = Scalar(1e-3));
276
279template <int _SupportOptions = SupportOptions::NoSweptSphere,
280 typename IndexType>
282 SupportSet& support_set, int& hint,
283 ShapeSupportData& support_data,
284 size_t /*unused*/ num_sampled_supports = 6,
285 Scalar tol = Scalar(1e-3));
286
293 SupportSet::Polygon& cvx_hull);
294
295} // namespace details
296} // namespace coal
297
298#endif // COAL_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:466
Base for convex polytope.
Definition geometric_shapes.h:691
Cylinder along Z axis. The cylinder is defined at its centroid.
Definition geometric_shapes.h:556
Ellipsoid centered at point zero.
Definition geometric_shapes.h:303
Base class for all basic geometric shapes.
Definition geometric_shapes.h:58
Center at zero point sphere.
Definition geometric_shapes.h:238
const Matrix3s & rotation() const
get rotation
Definition transform.h:113
Triangle stores the points instead of only indices of points.
Definition geometric_shapes.h:108
#define COAL_DLLAPI
Definition config.hh:88
SmallConvex< Triangle16::IndexType > SmallConvex16
Definition support_functions.h:124
@ NoSweptSphere
Definition support_data.h:57
void getShapeSupportSet(const TriangleP *triangle, SupportSet &support_set, int &, ShapeSupportData &, size_t num_sampled_supports=6, Scalar tol=Scalar(1e-3))
Triangle support set function. Assumes the support set frame has already been computed.
LargeConvex< Triangle16::IndexType > LargeConvex16
Definition support_functions.h:118
void getShapeSupport(const TriangleP *triangle, const Vec3s &dir, Vec3s &support, int &, ShapeSupportData &)
Triangle support function.
SmallConvex< Triangle32::IndexType > SmallConvex32
Definition support_functions.h:125
LargeConvex< Triangle32::IndexType > LargeConvex32
Definition support_functions.h:119
Vec3s getSupport(const ShapeBase *shape, const Vec3s &dir, int &hint)
the support function for shape. The output support point is expressed in the local frame of the shape...
void getSupportSet(const ShapeBase *shape, SupportSet &support_set, int &hint, size_t num_sampled_supports=6, Scalar tol=Scalar(1e-3))
Computes the support set for shape. This function assumes the frame of the support set has already be...
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...
Main namespace.
Definition broadphase_bruteforce.h:44
Matrix3s constructOrthonormalBasisFromVector(const Vec3s &vec)
Construct othonormal basis from vector. The z-axis is the normalized input vector.
Definition transform.h:261
Eigen::Matrix< Scalar, 3, 1 > Vec3s
Definition data_types.h:70
double Scalar
Definition data_types.h:68
This structure allows to encode contact patches. A contact patch is defined by a set of points belong...
Definition collision_data.h:511
Vec3s getNormal() const
Normal of the contact patch, expressed in the WORLD frame.
Definition collision_data.h:568
Transform3s 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:517
std::vector< Vec2s > Polygon
Definition collision_data.h:513
Cast a ConvexBase to a LargeConvex to use the log version of getShapeSupport. This is much faster tha...
Definition support_functions.h:117
Stores temporary data for the computation of support points.
Definition support_data.h:62
See LargeConvex.
Definition support_functions.h:123