coal 3.0.1
Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library
|
collision and distance solver based on the GJK and EPA algorithms. Originally, GJK and EPA were implemented in fcl which itself took inspiration from the code of the GJK in bullet. Since then, both GJK and EPA have been largely modified to be faster and more robust to numerical accuracy and edge cases. More...
#include <coal/narrowphase/narrowphase.h>
Public Member Functions | |
GJKSolver () | |
Default constructor for GJK algorithm By default, we don't want EPA to allocate memory because certain functions of the GJKSolver class have specializations which don't use EPA (and/or GJK). So we give EPA's constructor a max number of iterations of zero. Only the functions that need EPA will reset the algorithm and allocate memory if needed. | |
GJKSolver (const DistanceRequest &request) | |
Constructor from a DistanceRequest. | |
void | set (const DistanceRequest &request) |
setter from a DistanceRequest | |
GJKSolver (const CollisionRequest &request) | |
Constructor from a CollisionRequest. | |
void | set (const CollisionRequest &request) |
setter from a CollisionRequest | |
GJKSolver (const GJKSolver &other)=default | |
Copy constructor. | |
bool | operator== (const GJKSolver &other) const |
bool | operator!= (const GJKSolver &other) const |
Scalar | getDistancePrecision (const bool compute_penetration) const |
Helper to return the precision of the solver on the distance estimate, depending on whether or not compute_penetration is true. | |
template<typename S1 , typename S2 > | |
Scalar | shapeDistance (const S1 &s1, const Transform3s &tf1, const S2 &s2, const Transform3s &tf2, const bool compute_penetration, Vec3s &p1, Vec3s &p2, Vec3s &normal) const |
Uses GJK and EPA to compute the distance between two shapes. | |
template<typename S1 > | |
Scalar | shapeDistance (const S1 &s1, const Transform3s &tf1, const TriangleP &s2, const Transform3s &tf2, const bool compute_penetration, Vec3s &p1, Vec3s &p2, Vec3s &normal) const |
Partial specialization of shapeDistance for the case where the second shape is a triangle. It is more efficient to pre-compute the relative transformation between the two shapes before calling GJK/EPA. | |
template<typename S2 > | |
Scalar | shapeDistance (const TriangleP &s1, const Transform3s &tf1, const S2 &s2, const Transform3s &tf2, const bool compute_penetration, Vec3s &p1, Vec3s &p2, Vec3s &normal) const |
See other partial template specialization of shapeDistance above. | |
Public Attributes | |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW details::GJK | gjk |
GJK algorithm. | |
size_t | gjk_max_iterations |
maximum number of iterations of GJK | |
Scalar | gjk_tolerance |
tolerance of GJK | |
GJKInitialGuess | gjk_initial_guess |
which warm start to use for GJK | |
bool | enable_cached_guess |
Whether smart guess can be provided @Deprecated Use gjk_initial_guess instead. | |
Vec3s | cached_guess |
smart guess | |
support_func_guess_t | support_func_cached_guess |
smart guess for the support function | |
Scalar | distance_upper_bound |
If GJK can guarantee that the distance between the shapes is greater than this value, it will early stop. | |
GJKVariant | gjk_variant |
Variant of the GJK algorithm (Default, Nesterov or Polyak). | |
GJKConvergenceCriterion | gjk_convergence_criterion |
Convergence criterion for GJK. | |
GJKConvergenceCriterionType | gjk_convergence_criterion_type |
Absolute or relative convergence criterion for GJK. | |
details::EPA | epa |
EPA algorithm. | |
size_t | epa_max_iterations |
maximum number of iterations of EPA | |
Scalar | epa_tolerance |
tolerance of EPA | |
details::MinkowskiDiff | minkowski_difference |
Minkowski difference used by GJK and EPA algorithms. | |
collision and distance solver based on the GJK and EPA algorithms. Originally, GJK and EPA were implemented in fcl which itself took inspiration from the code of the GJK in bullet. Since then, both GJK and EPA have been largely modified to be faster and more robust to numerical accuracy and edge cases.
|
inline |
Default constructor for GJK algorithm By default, we don't want EPA to allocate memory because certain functions of the GJKSolver
class have specializations which don't use EPA (and/or GJK). So we give EPA's constructor a max number of iterations of zero. Only the functions that need EPA will reset the algorithm and allocate memory if needed.
|
inlineexplicit |
Constructor from a DistanceRequest.
[in] | request | DistanceRequest input |
See the default constructor; by default, we don't want EPA to allocate memory so we call EPA's constructor with 0 max number of iterations. However, the set
method stores the actual values of the request. EPA will thus allocate memory only if needed.
|
inlineexplicit |
Constructor from a CollisionRequest.
[in] | request | CollisionRequest input |
See the default constructor; by default, we don't want EPA to allocate memory so we call EPA's constructor with 0 max number of iterations. However, the set
method stores the actual values of the request. EPA will thus allocate memory only if needed.
|
inlineprotected |
|
inlineprotected |
Helper to return the precision of the solver on the distance estimate, depending on whether or not compute_penetration
is true.
|
inlineprotected |
initialize GJK. This method assumes minkowski_difference
has been set.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inline |
|
inline |
|
inlineprotected |
Runs the GJK algorithm.
`s1` | the first shape. | |
`tf1` | the transformation of the first shape. | |
`s2` | the second shape. | |
`tf2` | the transformation of the second shape. | |
`compute_penetration` | if true and if the shapes are in found in collision, the EPA algorithm is also ran to compute penetration information. | |
[out] | `distance` | the distance between the two shapes. |
[out] | `p1` | the witness point on the first shape. |
[out] | `p2` | the witness point on the second shape. |
[out] | `normal` | the normal of the collision, pointing from the first to the second shape. |
`relative_transformation_already_computed` | whether the relative transformation between the two shapes has already been computed. |
SupportOptions,see | MinkowskiDiff::set . Whether the support computations should take into account the shapes' swept-sphere radii during the iterations of GJK and EPA. Please leave this default value to false unless you know what you are doing. This template parameter is only used for debugging/testing purposes. In short, there is no need to take into account the swept sphere radius when computing supports in the iterations of GJK and EPA. GJK and EPA will correct the solution once they have converged. |
this->gjk.status
and this->epa.status
can be used to examine the status of GJK and EPA.
|
inline |
setter from a CollisionRequest
[in] | request | CollisionRequest input |
|
inline |
setter from a DistanceRequest
[in] | request | DistanceRequest input |
|
inline |
Uses GJK and EPA to compute the distance between two shapes.
`s1` | the first shape. | |
`tf1` | the transformation of the first shape. | |
`s2` | the second shape. | |
`tf2` | the transformation of the second shape. | |
`compute_penetration` | if true and GJK finds the shape in collision, the EPA algorithm is also ran to compute penetration information. | |
[out] | `p1` | the witness point on the first shape. |
[out] | `p2` | the witness point on the second shape. |
[out] | `normal` | the normal of the collision, pointing from the first to the second shape. |
this->distance_upper_bound
is set to a positive value, GJK will early stop if it finds the distance to be above this value. The distance returned by this->shapeDistance
will be a lower bound on the distance between the two shapes.this->gjk.status
and this->epa.status
can be used to examine the status of GJK and EPA.compute_penetration
is false, the distance is precise up to gjk_tolerance
.compute_penetration
is true, the distance is precise up to std::max(gjk_tolerance, epa_tolerance)
It's up to the user to decide whether the shapes are in collision or not, based on that estimate.
|
inline |
Partial specialization of shapeDistance
for the case where the second shape is a triangle. It is more efficient to pre-compute the relative transformation between the two shapes before calling GJK/EPA.
|
inline |
See other partial template specialization of shapeDistance above.
|
mutable |
smart guess
Scalar coal::GJKSolver::distance_upper_bound |
If GJK can guarantee that the distance between the shapes is greater than this value, it will early stop.
bool coal::GJKSolver::enable_cached_guess |
Whether smart guess can be provided @Deprecated Use gjk_initial_guess instead.
|
mutable |
EPA algorithm.
size_t coal::GJKSolver::epa_max_iterations |
maximum number of iterations of EPA
Scalar coal::GJKSolver::epa_tolerance |
tolerance of EPA
|
mutable |
GJK algorithm.
GJKConvergenceCriterion coal::GJKSolver::gjk_convergence_criterion |
Convergence criterion for GJK.
GJKConvergenceCriterionType coal::GJKSolver::gjk_convergence_criterion_type |
Absolute or relative convergence criterion for GJK.
GJKInitialGuess coal::GJKSolver::gjk_initial_guess |
which warm start to use for GJK
size_t coal::GJKSolver::gjk_max_iterations |
maximum number of iterations of GJK
Scalar coal::GJKSolver::gjk_tolerance |
tolerance of GJK
GJKVariant coal::GJKSolver::gjk_variant |
Variant of the GJK algorithm (Default, Nesterov or Polyak).
|
mutable |
Minkowski difference used by GJK and EPA algorithms.
|
mutable |
smart guess for the support function