coal 3.0.2
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
38
39#ifndef COAL_SUPPORT_FUNCTIONS_H
40#define COAL_SUPPORT_FUNCTIONS_H
41
45
46namespace coal {
47
48namespace details {
49
62
63// ============================================================================
64// ============================ SUPPORT FUNCTIONS =============================
65// ============================================================================
76template <int _SupportOptions = SupportOptions::NoSweptSphere>
77Vec3s getSupport(const ShapeBase* shape, const Vec3s& dir, int& hint);
78
80struct COAL_DLLAPI ShapeSupportData {
81 // @brief Tracks which points have been visited in a ConvexBase.
82 std::vector<int8_t> visited;
83
84 // @brief Tracks the last support direction used on this shape; used to
85 // warm-start the ConvexBase support function.
86 Vec3s last_dir = Vec3s::Zero();
87
88 // @brief Temporary set used to compute the convex-hull of a support set.
89 // Only used for ConvexBase and Box.
91};
92
94template <int _SupportOptions = SupportOptions::NoSweptSphere>
95void getShapeSupport(const TriangleP* triangle, const Vec3s& dir,
96 Vec3s& support, int& /*unused*/,
97 ShapeSupportData& /*unused*/);
98
100template <int _SupportOptions = SupportOptions::NoSweptSphere>
101void getShapeSupport(const Box* box, const Vec3s& dir, Vec3s& support,
102 int& /*unused*/, ShapeSupportData& /*unused*/);
103
105template <int _SupportOptions = SupportOptions::NoSweptSphere>
106void getShapeSupport(const Sphere* sphere, const Vec3s& dir, Vec3s& support,
107 int& /*unused*/, ShapeSupportData& /*unused*/);
108
110template <int _SupportOptions = SupportOptions::NoSweptSphere>
111void getShapeSupport(const Ellipsoid* ellipsoid, const Vec3s& dir,
112 Vec3s& support, int& /*unused*/,
113 ShapeSupportData& /*unused*/);
114
116template <int _SupportOptions = SupportOptions::NoSweptSphere>
117void getShapeSupport(const Capsule* capsule, const Vec3s& dir, Vec3s& support,
118 int& /*unused*/, ShapeSupportData& /*unused*/);
119
121template <int _SupportOptions = SupportOptions::NoSweptSphere>
122void getShapeSupport(const Cone* cone, const Vec3s& dir, Vec3s& support,
123 int& /*unused*/, ShapeSupportData& /*unused*/);
124
126template <int _SupportOptions = SupportOptions::NoSweptSphere>
127void getShapeSupport(const Cylinder* cylinder, const Vec3s& dir, Vec3s& support,
128 int& /*unused*/, ShapeSupportData& /*unused*/);
129
133template <int _SupportOptions = SupportOptions::NoSweptSphere>
134void getShapeSupport(const ConvexBase* convex, const Vec3s& dir, Vec3s& support,
135 int& hint, ShapeSupportData& /*unused*/);
136
145
147template <int _SupportOptions = SupportOptions::NoSweptSphere>
148void getShapeSupport(const SmallConvex* convex, const Vec3s& dir,
149 Vec3s& support, int& hint, ShapeSupportData& data);
150
152template <int _SupportOptions = SupportOptions::NoSweptSphere>
153void getShapeSupport(const LargeConvex* convex, const Vec3s& dir,
154 Vec3s& support, int& hint, ShapeSupportData& support_data);
155
156// ============================================================================
157// ========================== SUPPORT SET FUNCTIONS ===========================
158// ============================================================================
194template <int _SupportOptions = SupportOptions::NoSweptSphere>
195void getSupportSet(const ShapeBase* shape, SupportSet& support_set, int& hint,
196 size_t num_sampled_supports = 6, CoalScalar tol = 1e-3);
197
205template <int _SupportOptions = SupportOptions::NoSweptSphere>
206void getSupportSet(const ShapeBase* shape, const Vec3s& dir,
207 SupportSet& support_set, int& hint,
208 size_t num_sampled_supports = 6, CoalScalar tol = 1e-3) {
210 const Vec3s& support_dir = support_set.getNormal();
211 const Vec3s support = getSupport<_SupportOptions>(shape, support_dir, hint);
212 getSupportSet<_SupportOptions>(shape, support_set, hint, num_sampled_supports,
213 tol);
214}
215
218template <int _SupportOptions = SupportOptions::NoSweptSphere>
219void getShapeSupportSet(const TriangleP* triangle, SupportSet& support_set,
220 int& /*unused*/, ShapeSupportData& /*unused*/,
221 size_t /*unused*/ num_sampled_supports = 6,
222 CoalScalar tol = 1e-3);
223
226template <int _SupportOptions = SupportOptions::NoSweptSphere>
227void getShapeSupportSet(const Box* box, SupportSet& support_set,
228 int& /*unused*/, ShapeSupportData& support_data,
229 size_t /*unused*/ num_sampled_supports = 6,
230 CoalScalar tol = 1e-3);
231
234template <int _SupportOptions = SupportOptions::NoSweptSphere>
235void getShapeSupportSet(const Sphere* sphere, SupportSet& support_set,
236 int& /*unused*/, ShapeSupportData& /*unused*/,
237 size_t /*unused*/ num_sampled_supports = 6,
238 CoalScalar /*unused*/ tol = 1e-3);
239
242template <int _SupportOptions = SupportOptions::NoSweptSphere>
243void getShapeSupportSet(const Ellipsoid* ellipsoid, SupportSet& support_set,
244 int& /*unused*/, ShapeSupportData& /*unused*/,
245 size_t /*unused*/ num_sampled_supports = 6,
246 CoalScalar /*unused*/ tol = 1e-3);
247
250template <int _SupportOptions = SupportOptions::NoSweptSphere>
251void getShapeSupportSet(const Capsule* capsule, SupportSet& support_set,
252 int& /*unused*/, ShapeSupportData& /*unused*/,
253 size_t /*unused*/ num_sampled_supports = 6,
254 CoalScalar tol = 1e-3);
255
258template <int _SupportOptions = SupportOptions::NoSweptSphere>
259void getShapeSupportSet(const Cone* cone, SupportSet& support_set,
260 int& /*unused*/, ShapeSupportData& /*unused*/,
261 size_t num_sampled_supports = 6, CoalScalar tol = 1e-3);
262
265template <int _SupportOptions = SupportOptions::NoSweptSphere>
266void getShapeSupportSet(const Cylinder* cylinder, SupportSet& support_set,
267 int& /*unused*/, ShapeSupportData& /*unused*/,
268 size_t num_sampled_supports = 6, CoalScalar tol = 1e-3);
269
274template <int _SupportOptions = SupportOptions::NoSweptSphere>
275void getShapeSupportSet(const ConvexBase* convex, SupportSet& support_set,
276 int& hint, ShapeSupportData& support_data,
277 size_t /*unused*/ num_sampled_supports = 6,
278 CoalScalar tol = 1e-3);
279
282template <int _SupportOptions = SupportOptions::NoSweptSphere>
283void getShapeSupportSet(const SmallConvex* convex, SupportSet& support_set,
284 int& /*unused*/, ShapeSupportData& /*unused*/,
285 size_t /*unused*/ num_sampled_supports = 6,
286 CoalScalar tol = 1e-3);
287
290template <int _SupportOptions = SupportOptions::NoSweptSphere>
291void getShapeSupportSet(const LargeConvex* convex, SupportSet& support_set,
292 int& hint, ShapeSupportData& support_data,
293 size_t /*unused*/ num_sampled_supports = 6,
294 CoalScalar tol = 1e-3);
295
302 SupportSet::Polygon& cvx_hull);
303
304} // namespace details
305
306} // namespace coal
307
308#endif // COAL_SUPPORT_FUNCTIONS_H
Center at zero point, axis aligned box.
Definition geometric_shapes.h:166
Capsule It is where is the distance between the point x and the capsule segment AB,...
Definition geometric_shapes.h:383
Cone The base of the cone is at and the top is at .
Definition geometric_shapes.h:467
Base for convex polytope.
Definition geometric_shapes.h:645
Cylinder along Z axis. The cylinder is defined at its centroid.
Definition geometric_shapes.h:560
Ellipsoid centered at point zero.
Definition geometric_shapes.h:305
Base class for all basic geometric shapes.
Definition geometric_shapes.h:58
Center at zero point sphere.
Definition geometric_shapes.h:240
const Matrix3s & rotation() const
get rotation
Definition transform.h:113
Triangle stores the points instead of only indices of points.
Definition geometric_shapes.h:110
ShapeBase()
Definition geometric_shapes.h:60
Definition hfield.h:170
void getSupportSet(const ShapeBase *shape, SupportSet &support_set, int &hint, size_t num_sampled_supports=6, CoalScalar tol=1e-3)
Computes the support set for shape. This function assumes the frame of the support set has already be...
SupportOptions
Options for the computation of support points. NoSweptSphere option is used when the support function...
Definition support_functions.h:58
@ WithSweptSphere
Definition support_functions.h:60
@ NoSweptSphere
Definition support_functions.h:59
void getShapeSupport(const TriangleP *triangle, const Vec3s &dir, Vec3s &support, int &, ShapeSupportData &)
Triangle support function.
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 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...
void getShapeSupportSet(const TriangleP *triangle, SupportSet &support_set, int &, ShapeSupportData &, size_t num_sampled_supports=6, CoalScalar tol=1e-3)
Triangle support set function. Assumes the support set frame has already been computed.
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:262
ContactPatch SupportSet
Structure used for internal computations. A support set and a contact patch can be represented by the...
Definition collision_data.h:721
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
Definition data_types.h:77
double CoalScalar
Definition data_types.h:76
Vec3s getNormal() const
Normal of the contact patch, expressed in the WORLD frame.
Definition collision_data.h:569
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:518
std::vector< Vec2s > 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:142
Stores temporary data for the computation of support points.
Definition support_functions.h:80
SupportSet::Polygon polygon
Definition support_functions.h:90
std::vector< int8_t > visited
Definition support_functions.h:82
Vec3s last_dir
Definition support_functions.h:86
See LargeConvex.
Definition support_functions.h:144