contact_patch_solver.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2024, INRIA
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of INRIA nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
38 
39 namespace coal {
40 
41 namespace details {
42 
44 template <typename ShapeType,
45  int _SupportOptions = SupportOptions::NoSweptSphere>
46 void getShapeSupportSetTpl(const ShapeBase* shape, SupportSet& support_set,
47  int& hint, ShapeSupportData& support_data,
48  size_t num_sampled_supports = 6,
49  CoalScalar tol = 1e-3) {
50  const ShapeType* shape_ = static_cast<const ShapeType*>(shape);
51  getShapeSupportSet<_SupportOptions>(shape_, support_set, hint, support_data,
52  num_sampled_supports, tol);
53 }
54 
55 } // namespace details
56 
57 // ============================================================================
60  ShapeSupportData& support_data) {
61  // Note: because the swept-sphere radius was already taken into account when
62  // constructing the contact patch frame, there is actually no need to take the
63  // swept-sphere radius of shapes into account. The origin of the contact patch
64  // frame already encodes this information.
65  using Options = details::SupportOptions;
66  switch (shape->getNodeType()) {
67  case GEOM_TRIANGLE:
68  return details::getShapeSupportSetTpl<TriangleP, Options::NoSweptSphere>;
69  case GEOM_BOX: {
70  const size_t num_corners_box = 8;
71  support_data.polygon.reserve(num_corners_box);
72  return details::getShapeSupportSetTpl<Box, Options::NoSweptSphere>;
73  }
74  case GEOM_SPHERE:
75  return details::getShapeSupportSetTpl<Sphere, Options::NoSweptSphere>;
76  case GEOM_ELLIPSOID:
77  return details::getShapeSupportSetTpl<Ellipsoid, Options::NoSweptSphere>;
78  case GEOM_CAPSULE:
79  return details::getShapeSupportSetTpl<Capsule, Options::NoSweptSphere>;
80  case GEOM_CONE:
81  return details::getShapeSupportSetTpl<Cone, Options::NoSweptSphere>;
82  case GEOM_CYLINDER:
83  return details::getShapeSupportSetTpl<Cylinder, Options::NoSweptSphere>;
84  case GEOM_CONVEX: {
85  const ConvexBase* convex = static_cast<const ConvexBase*>(shape);
86  if (support_data.polygon.capacity() < default_num_preallocated_supports) {
87  support_data.polygon.reserve(default_num_preallocated_supports);
88  }
89  if ((size_t)(convex->num_points) >
91  support_data.visited.assign(convex->num_points, false);
92  support_data.last_dir.setZero();
95  } else {
98  }
99  }
100  default:
101  COAL_THROW_PRETTY("Unsupported geometric shape.", std::logic_error);
102  }
103 }
104 
105 } // namespace coal
coal::CollisionGeometry::getNodeType
virtual NODE_TYPE getNodeType() const
get the node type
Definition: coal/collision_object.h:130
coal::details::getShapeSupportSetTpl
void getShapeSupportSetTpl(const ShapeBase *shape, SupportSet &support_set, int &hint, ShapeSupportData &support_data, size_t num_sampled_supports=6, CoalScalar tol=1e-3)
Templated shape support set functions.
Definition: contact_patch_solver.cpp:46
coal::ConvexBase::num_points
unsigned int num_points
Definition: coal/shape/geometric_shapes.h:720
coal::ContactPatchSolver::SupportSetFunction
void(* SupportSetFunction)(const ShapeBase *shape, SupportSet &support_set, int &hint, ShapeSupportData &support_data, size_t num_sampled_supports, CoalScalar tol)
Support set function for shape si.
Definition: coal/contact_patch/contact_patch_solver.h:84
coal::details::ShapeSupportData
Stores temporary data for the computation of support points.
Definition: coal/narrowphase/support_functions.h:80
coal::GEOM_CONE
@ GEOM_CONE
Definition: coal/collision_object.h:77
coal::GEOM_CONVEX
@ GEOM_CONVEX
Definition: coal/collision_object.h:79
coal::details::ShapeSupportData::visited
std::vector< int8_t > visited
Definition: coal/narrowphase/support_functions.h:82
coal::details::ShapeSupportData::last_dir
Vec3s last_dir
Definition: coal/narrowphase/support_functions.h:86
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
coal::GEOM_CAPSULE
@ GEOM_CAPSULE
Definition: coal/collision_object.h:76
coal::details::NoSweptSphere
@ NoSweptSphere
Definition: coal/narrowphase/support_functions.h:59
coal::GEOM_SPHERE
@ GEOM_SPHERE
Definition: coal/collision_object.h:75
coal::ContactPatch
This structure allows to encode contact patches. A contact patch is defined by a set of points belong...
Definition: coal/collision_data.h:512
coal::GEOM_ELLIPSOID
@ GEOM_ELLIPSOID
Definition: coal/collision_object.h:84
coal::ShapeBase
Base class for all basic geometric shapes.
Definition: coal/shape/geometric_shapes.h:58
COAL_THROW_PRETTY
#define COAL_THROW_PRETTY(message, exception)
Definition: include/coal/fwd.hh:64
coal::GEOM_TRIANGLE
@ GEOM_TRIANGLE
Definition: coal/collision_object.h:82
coal::details::ShapeSupportData::polygon
SupportSet::Polygon polygon
Definition: coal/narrowphase/support_functions.h:90
coal::GEOM_CYLINDER
@ GEOM_CYLINDER
Definition: coal/collision_object.h:78
coal::details::LargeConvex
Cast a ConvexBase to a LargeConvex to use the log version of getShapeSupport. This is much faster tha...
Definition: coal/narrowphase/support_functions.h:142
coal::details::SmallConvex
See LargeConvex.
Definition: coal/narrowphase/support_functions.h:144
coal::ContactPatchSolver::default_num_preallocated_supports
static constexpr size_t default_num_preallocated_supports
Number of vectors to pre-allocate in the m_clipping_sets vectors.
Definition: coal/contact_patch/contact_patch_solver.h:91
coal::ContactPatchSolver::makeSupportSetFunction
static SupportSetFunction makeSupportSetFunction(const ShapeBase *shape, ShapeSupportData &support_data)
Construct support set function for shape.
Definition: contact_patch_solver.cpp:59
contact_patch_solver.h
coal::GEOM_BOX
@ GEOM_BOX
Definition: coal/collision_object.h:74
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76
coal::details::SupportOptions
SupportOptions
Options for the computation of support points. NoSweptSphere option is used when the support function...
Definition: coal/narrowphase/support_functions.h:58
coal::ConvexBase::num_vertices_large_convex_threshold
static constexpr size_t num_vertices_large_convex_threshold
Above this threshold, the convex polytope is considered large. This influcences the way the support f...
Definition: coal/shape/geometric_shapes.h:716
coal::ConvexBase
Base for convex polytope.
Definition: coal/shape/geometric_shapes.h:645


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57