Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing gjk utils #302

Merged
merged 25 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dcabc6c
collision queries: exposing GJK tolerance & max_iterations
lmontaut Jun 1, 2022
c6438a0
misc: removing set functions in GJKSolver & better naming for converg…
lmontaut Jun 1, 2022
21cba6c
python: exposing gjk_variant & convergence_criterion to query requests
lmontaut Jun 1, 2022
6ffadbd
misc: removing set/get in GJK class for variant and cv related attrib…
lmontaut Jun 2, 2022
da3aa19
core: adding enum for initial guess in GJKSolver
lmontaut Jun 2, 2022
381ec6a
core: introducing initialize_gjk function for GJKSolver
lmontaut Jun 2, 2022
8f6fa85
core: using initialize_gjk in GJKSolver
lmontaut Jun 2, 2022
bfd2e5d
queries: adding gjk_initial_guess
lmontaut Jun 2, 2022
99310ab
col/dist api: gjk_initial_guess in collide/distance functions and fun…
lmontaut Jun 2, 2022
db25e42
core: removing setting gjk related stuff (already set by collide/dist…
lmontaut Jun 2, 2022
7650fd6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 2, 2022
8a69c97
col/dist api: adding gjk_variant and cv criterion in functors
lmontaut Jun 2, 2022
bafec21
misc: moving the deprecated flag
lmontaut Jun 2, 2022
492f0ff
core: concatenating enable_cached_guess and gjk_initial_guess
lmontaut Jun 2, 2022
1d92924
core: check in initialize_gjk in GJKSolver
lmontaut Jun 3, 2022
d5e9da6
python: fix exception type
jcarpent Jun 3, 2022
7f33182
core: add HPP_FCL_COMPILER_DIAGNOSTIC helper macros
jcarpent Jun 3, 2022
6d9945d
core: move header includes to correct location
jcarpent Jun 3, 2022
3b0edce
cmake: add missing files to the list
jcarpent Jun 3, 2022
8a44d80
test: fix type to remove warning
jcarpent Jun 3, 2022
4ed789a
cmake: sync submodule
jcarpent Jun 3, 2022
03d4f5f
core: use HPP_FCL_DEPRECATED_MESSAGE
jcarpent Jun 3, 2022
cf0c45b
core: fix deprecated warnings
jcarpent Jun 3, 2022
4b3f810
python: fix exposition of enable_cached_gjk_guess
jcarpent Jun 3, 2022
2c37457
test: fix warnings
jcarpent Jun 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake
Submodule cmake updated 1 files
+9 −3 deprecated.hh.cmake
48 changes: 42 additions & 6 deletions include/hpp/fcl/collision_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,28 @@ struct QueryResult;

/// @brief base class for all query requests
struct HPP_FCL_DLLAPI QueryRequest {
// @briefInitial guess to use for the GJK algorithm
GJKInitialGuess gjk_initial_guess;

/// @brief whether enable gjk initial guess
/// @Deprecated Use gjk_initial_guess instead
HPP_FCL_DEPRECATED_MESSAGE("Use gjk_initial_guess instead")
bool enable_cached_gjk_guess;

/// @brief whether to enable the Nesterov accleration of GJK
GJKVariant gjk_variant;

/// @brief convergence criterion used to stop GJK
GJKConvergenceCriterion convergence_criterion;
GJKConvergenceCriterion gjk_convergence_criterion;

/// @brief convergence criterion used to stop GJK
GJKConvergenceCriterionType convergence_criterion_type;
GJKConvergenceCriterionType gjk_convergence_criterion_type;

/// @brief tolerance for the GJK algorithm
FCL_REAL gjk_tolerance;

/// @brief maximum iteration for the GJK algorithm
size_t gjk_max_iterations;

/// @brief the gjk initial guess set by user
Vec3f cached_gjk_guess;
Expand All @@ -138,23 +149,40 @@ struct HPP_FCL_DLLAPI QueryRequest {
/// @brief enable timings when performing collision/distance request
bool enable_timings;

HPP_FCL_COMPILER_DIAGNOSTIC_PUSH
HPP_FCL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
/// @brief Default constructor.
QueryRequest()
: enable_cached_gjk_guess(false),
: gjk_initial_guess(GJKInitialGuess::DefaultGuess),
enable_cached_gjk_guess(false),
gjk_variant(GJKVariant::DefaultGJK),
convergence_criterion(GJKConvergenceCriterion::VDB),
convergence_criterion_type(GJKConvergenceCriterionType::Relative),
gjk_convergence_criterion(GJKConvergenceCriterion::VDB),
gjk_convergence_criterion_type(GJKConvergenceCriterionType::Relative),
gjk_tolerance(1e-6),
gjk_max_iterations(128),
cached_gjk_guess(1, 0, 0),
cached_support_func_guess(support_func_guess_t::Zero()),
enable_timings(false) {}

/// @brief Copy constructor.
QueryRequest(const QueryRequest& other) = default;

/// @brief Copy assignment operator.
QueryRequest& operator=(const QueryRequest& other) = default;
HPP_FCL_COMPILER_DIAGNOSTIC_POP

void updateGuess(const QueryResult& result);

/// @brief whether two QueryRequest are the same or not
inline bool operator==(const QueryRequest& other) const {
return enable_cached_gjk_guess == other.enable_cached_gjk_guess &&
HPP_FCL_COMPILER_DIAGNOSTIC_PUSH
HPP_FCL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
return gjk_initial_guess == other.gjk_initial_guess &&
enable_cached_gjk_guess == other.enable_cached_gjk_guess &&
cached_gjk_guess == other.cached_gjk_guess &&
cached_support_func_guess == other.cached_support_func_guess &&
enable_timings == other.enable_timings;
HPP_FCL_COMPILER_DIAGNOSTIC_POP
}
};

Expand All @@ -175,10 +203,18 @@ struct HPP_FCL_DLLAPI QueryResult {
};

inline void QueryRequest::updateGuess(const QueryResult& result) {
if (gjk_initial_guess == GJKInitialGuess::CachedGuess) {
cached_gjk_guess = result.cached_gjk_guess;
cached_support_func_guess = result.cached_support_func_guess;
}
// TODO: use gjk_initial_guess instead
jcarpent marked this conversation as resolved.
Show resolved Hide resolved
HPP_FCL_COMPILER_DIAGNOSTIC_PUSH
HPP_FCL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
if (enable_cached_gjk_guess) {
cached_gjk_guess = result.cached_gjk_guess;
cached_support_func_guess = result.cached_support_func_guess;
}
HPP_FCL_COMPILER_DIAGNOSTIC_POP
}

struct CollisionResult;
Expand Down
8 changes: 8 additions & 0 deletions include/hpp/fcl/data_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ typedef Eigen::Matrix<Eigen::DenseIndex, Eigen::Dynamic, 3> Matrixx3i;
typedef Eigen::Matrix<FCL_REAL, Eigen::Dynamic, Eigen::Dynamic> MatrixXf;
typedef Eigen::Vector2i support_func_guess_t;

/// @brief Initial guess to use for the GJK algorithm
/// DefaultGuess: Vec3f(1, 0, 0)
/// CachedGuess: previous vector found by GJK or guess cached by the user
/// BoundingVolumeGuess: guess using the centers of the shapes' AABB
/// WARNING: to use BoundingVolumeGuess, computeLocalAABB must have been called
/// on the two shapes.
enum GJKInitialGuess { DefaultGuess, CachedGuess, BoundingVolumeGuess };

/// @brief Variant to use for the GJK algorithm
enum GJKVariant { DefaultGJK, NesterovAcceleration };

Expand Down
19 changes: 19 additions & 0 deletions include/hpp/fcl/fwd.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Software License Agreement (BSD License)
//
// Copyright (c) 2014, CNRS-LAAS
// Copyright (c) 2022, Inria
// Author: Florent Lamiraux
//
// All rights reserved.
Expand Down Expand Up @@ -41,6 +42,8 @@
#include <sstream>

#include <hpp/fcl/config.hh>
#include <hpp/fcl/deprecated.hh>
#include <hpp/fcl/warning.hh>

#if _WIN32
#define HPP_FCL_PRETTY_FUNCTION __FUNCSIG__
Expand All @@ -64,6 +67,22 @@
#define HPP_FCL_WITH_CXX11_SUPPORT
#endif

#if defined(__GNUC__) || defined(__clang__)
#define HPP_FCL_COMPILER_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
#define HPP_FCL_COMPILER_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
#define HPP_FCL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#elif defined(WIN32)
#define HPP_FCL_COMPILER_DIAGNOSTIC_PUSH _Pragma("warning(push)")
#define HPP_FCL_COMPILER_DIAGNOSTIC_POP _Pragma("warning(pop)")
#define HPP_FCL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS \
_Pragma("warning(disable : 4996)")
#else
#define HPP_FCL_COMPILER_DIAGNOSTIC_PUSH
#define HPP_FCL_COMPILER_DIAGNOSTIC_POP
#define HPP_FCL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
#endif // __GNUC__

namespace hpp {
namespace fcl {
using std::dynamic_pointer_cast;
Expand Down
2 changes: 0 additions & 2 deletions include/hpp/fcl/internal/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
#include <iostream>
#include <limits>

#include <hpp/fcl/deprecated.hh>
#include <hpp/fcl/config.hh>
#include <hpp/fcl/data_types.h>

namespace hpp {
Expand Down
26 changes: 3 additions & 23 deletions include/hpp/fcl/narrowphase/gjk.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ struct HPP_FCL_DLLAPI GJK {

MinkowskiDiff const* shape;
Vec3f ray;
GJKVariant gjk_variant;
GJKConvergenceCriterion convergence_criterion;
GJKConvergenceCriterionType convergence_criterion_type;
support_func_guess_t support_hint;
/// The distance computed by GJK. The possible values are
/// - \f$ d = - R - 1 \f$ when a collision is detected and GJK
Expand Down Expand Up @@ -249,31 +252,11 @@ struct HPP_FCL_DLLAPI GJK {
distance_upper_bound = dup;
}

/// @brief Set which GJK version to use. Default is Vanilla.
inline void setGJKVariant(GJKVariant variant) { gjk_variant = variant; }
inline GJKVariant getGJKVariant() { return gjk_variant; }

/// @brief Convergence check used to stop GJK when shapes are not in
/// collision.
bool checkConvergence(const Vec3f& w, const FCL_REAL& rl, FCL_REAL& alpha,
const FCL_REAL& omega);

inline void setConvergenceCriterion(
const GJKConvergenceCriterion& criterion) {
convergence_criterion = criterion;
}
inline GJKConvergenceCriterion getConvergenceCriterion() {
return convergence_criterion;
}

inline void setConvergenceCriterionType(
const GJKConvergenceCriterionType& criterion_type) {
convergence_criterion_type = criterion_type;
}
inline GJKConvergenceCriterionType getConvergenceCriterionType() {
return convergence_criterion_type;
}

/// @brief Get GJK number of iterations.
inline size_t getIterations() { return iterations; }

Expand All @@ -288,10 +271,7 @@ struct HPP_FCL_DLLAPI GJK {
unsigned int max_iterations;
FCL_REAL tolerance;
FCL_REAL distance_upper_bound;
GJKVariant gjk_variant;
size_t iterations;
GJKConvergenceCriterion convergence_criterion;
GJKConvergenceCriterionType convergence_criterion_type;

/// @brief discard one vertex from the simplex
inline void removeVertex(Simplex& simplex);
Expand Down
Loading