Solver to compute contact patches, i.e. the intersection between two contact surfaces projected onto the shapes' separating plane. Otherwise said, a contact patch is simply the intersection between two support sets: the support set of shape S1 in direction n
and the support set of shape S2 in direction -n
, where n
is the contact normal (satisfying the optimality conditions of GJK/EPA).
More...
#include <contact_patch_solver.h>
Public Types | |
using | ShapeSupportData = details::ShapeSupportData |
using | SupportSetDirection = SupportSet::PatchDirection |
typedef 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. More... | |
Public Member Functions | |
template<typename ShapeType1 , typename ShapeType2 > | |
void | computePatch (const ShapeType1 &s1, const Transform3s &tf1, const ShapeType2 &s2, const Transform3s &tf2, const Contact &contact, ContactPatch &contact_patch) const |
Main API of the solver: compute a contact patch from a contact between shapes s1 and s2. The contact patch is the (triple) intersection between the separating plane passing (by contact.pos and supported by contact.normal ) and the shapes s1 and s2. More... | |
ContactPatchSolver () | |
Default constructor. More... | |
ContactPatchSolver (const ContactPatchRequest &request) | |
Construct the solver with a ContactPatchRequest . More... | |
void | getResult (const Contact &contact, const ContactPatch::Polygon *result, ContactPatch &contact_patch) const |
Retrieve result, adds a post-processing step if result has bigger size than this->max_patch_size . More... | |
bool | operator== (const ContactPatchSolver &other) const |
template<typename ShapeType1 , typename ShapeType2 > | |
void | reset (const ShapeType1 &shape1, const Transform3s &tf1, const ShapeType2 &shape2, const Transform3s &tf2, const ContactPatch &contact_patch) const |
Reset the internal quantities of the solver. More... | |
void | set (const ContactPatchRequest &request) |
Set up the solver using a ContactPatchRequest . More... | |
void | setSupportGuess (const support_func_guess_t guess) const |
Sets the support guess used during support set computation of shapes s1 and s2. More... | |
Static Public Member Functions | |
static Vec2s | computeLineSegmentIntersection (const Vec2s &a, const Vec2s &b, const Vec2s &c, const Vec2s &d) |
static SupportSetFunction | makeSupportSetFunction (const ShapeBase *shape, ShapeSupportData &support_data) |
Construct support set function for shape. More... | |
Public Attributes | |
std::vector< bool > | added_to_patch |
Tracks which point of the Sutherland-Hodgman result have been added to the contact patch. Only used if the post-processing step occurs, i.e. if the result of Sutherland-Hodgman has a size bigger than max_patch_size . More... | |
size_t | num_samples_curved_shapes |
Number of points sampled for Cone and Cylinder when the normal is orthogonal to the shapes' basis. See ContactPatchRequest::m_num_samples_curved_shapes for more details. More... | |
CoalScalar | patch_tolerance |
Tolerance below which points are added to the shapes support sets. See ContactPatchRequest::m_patch_tolerance for more details. More... | |
support_func_guess_t | support_guess |
Guess for the support sets computation. More... | |
SupportSet | support_set_buffer |
Temporary support set used for the Sutherland-Hodgman algorithm. More... | |
SupportSet | support_set_shape1 |
Holder for support set of shape 1, used for internal computation. After computePatch has been called, this support set is no longer valid. More... | |
SupportSet | support_set_shape2 |
Holder for support set of shape 2, used for internal computation. After computePatch has been called, this support set is no longer valid. More... | |
SupportSetFunction | supportFuncShape1 |
Support set function for shape s1. More... | |
SupportSetFunction | supportFuncShape2 |
Support set function for shape s2. More... | |
std::array< ShapeSupportData, 2 > | supports_data |
Temporary data to compute the support sets on each shape. More... | |
Static Public Attributes | |
static constexpr size_t | default_num_preallocated_supports = 16 |
Number of vectors to pre-allocate in the m_clipping_sets vectors. More... | |
Solver to compute contact patches, i.e. the intersection between two contact surfaces projected onto the shapes' separating plane. Otherwise said, a contact patch is simply the intersection between two support sets: the support set of shape S1 in direction n
and the support set of shape S2 in direction -n
, where n
is the contact normal (satisfying the optimality conditions of GJK/EPA).
TODO(louis): algo improvement:
Definition at line 59 of file coal/contact_patch/contact_patch_solver.h.
Definition at line 62 of file coal/contact_patch/contact_patch_solver.h.
Definition at line 63 of file coal/contact_patch/contact_patch_solver.h.
typedef void(* coal::ContactPatchSolver::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.
[in] | shape | the shape. |
[in/out] | support_set a support set of the shape. A support set is attached to a frame. All the points of the set computed by this function will be expressed in the local frame of the support set. The support set is computed in the direction of the positive z-axis if its direction is DEFAULT, negative z-axis if its direction is INVERTED. | |
[in/out] | hint for the support computation of ConvexBase shapes. Gets updated after calling the function onto ConvexBase shapes. | |
[in/out] | support_data for the support computation of ConvexBase shapes. Gets updated with visited vertices after calling the function onto ConvexBase shapes. | |
[in] | num_sampled_supports | for shapes like cone or cylinders which have smooth non-strictly convex sides (their bases are circles), we need to know how many supports we sample from these sides. For any other shape, this parameter is not used. |
[in] | tol | the "thickness" of the support plane. Any point v which satisfies max_{x in shape}(x.dot(dir)) - v.dot(dir) <= tol is tol distant from the support plane and is added to the support set. |
Definition at line 84 of file coal/contact_patch/contact_patch_solver.h.
|
inlineexplicit |
Default constructor.
Definition at line 133 of file coal/contact_patch/contact_patch_solver.h.
|
inlineexplicit |
Construct the solver with a ContactPatchRequest
.
Definition at line 144 of file coal/contact_patch/contact_patch_solver.h.
|
static |
void coal::ContactPatchSolver::computePatch | ( | const ShapeType1 & | s1, |
const Transform3s & | tf1, | ||
const ShapeType2 & | s2, | ||
const Transform3s & | tf2, | ||
const Contact & | contact, | ||
ContactPatch & | contact_patch | ||
) | const |
Main API of the solver: compute a contact patch from a contact between shapes s1 and s2. The contact patch is the (triple) intersection between the separating plane passing (by contact.pos
and supported by contact.normal
) and the shapes s1 and s2.
void coal::ContactPatchSolver::getResult | ( | const Contact & | contact, |
const ContactPatch::Polygon * | result, | ||
ContactPatch & | contact_patch | ||
) | const |
Retrieve result, adds a post-processing step if result has bigger size than this->max_patch_size
.
|
static |
Construct support set function for shape.
Definition at line 59 of file contact_patch_solver.cpp.
|
inline |
Definition at line 190 of file coal/contact_patch/contact_patch_solver.h.
void coal::ContactPatchSolver::reset | ( | const ShapeType1 & | shape1, |
const Transform3s & | tf1, | ||
const ShapeType2 & | shape2, | ||
const Transform3s & | tf2, | ||
const ContactPatch & | contact_patch | ||
) | const |
Reset the internal quantities of the solver.
void coal::ContactPatchSolver::set | ( | const ContactPatchRequest & | request | ) |
Set up the solver using a ContactPatchRequest
.
|
inline |
Sets the support guess used during support set computation of shapes s1 and s2.
Definition at line 153 of file coal/contact_patch/contact_patch_solver.h.
|
mutable |
Tracks which point of the Sutherland-Hodgman result have been added to the contact patch. Only used if the post-processing step occurs, i.e. if the result of Sutherland-Hodgman has a size bigger than max_patch_size
.
Definition at line 130 of file coal/contact_patch/contact_patch_solver.h.
|
staticconstexpr |
Number of vectors to pre-allocate in the m_clipping_sets
vectors.
Definition at line 91 of file coal/contact_patch/contact_patch_solver.h.
size_t coal::ContactPatchSolver::num_samples_curved_shapes |
Number of points sampled for Cone and Cylinder when the normal is orthogonal to the shapes' basis. See ContactPatchRequest::m_num_samples_curved_shapes for more details.
Definition at line 97 of file coal/contact_patch/contact_patch_solver.h.
CoalScalar coal::ContactPatchSolver::patch_tolerance |
Tolerance below which points are added to the shapes support sets. See ContactPatchRequest::m_patch_tolerance for more details.
Definition at line 101 of file coal/contact_patch/contact_patch_solver.h.
|
mutable |
Guess for the support sets computation.
Definition at line 113 of file coal/contact_patch/contact_patch_solver.h.
|
mutable |
Temporary support set used for the Sutherland-Hodgman algorithm.
Definition at line 124 of file coal/contact_patch/contact_patch_solver.h.
|
mutable |
Holder for support set of shape 1, used for internal computation. After computePatch
has been called, this support set is no longer valid.
Definition at line 117 of file coal/contact_patch/contact_patch_solver.h.
|
mutable |
Holder for support set of shape 2, used for internal computation. After computePatch
has been called, this support set is no longer valid.
Definition at line 121 of file coal/contact_patch/contact_patch_solver.h.
|
mutable |
Support set function for shape s1.
Definition at line 104 of file coal/contact_patch/contact_patch_solver.h.
|
mutable |
Support set function for shape s2.
Definition at line 107 of file coal/contact_patch/contact_patch_solver.h.
|
mutable |
Temporary data to compute the support sets on each shape.
Definition at line 110 of file coal/contact_patch/contact_patch_solver.h.