box_box_collision.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE BOX_BOX_COLLISION
2 #include <boost/test/included/unit_test.hpp>
3 
4 #include <Eigen/Geometry>
8 
9 #include "utility.h"
10 
11 using hpp::fcl::Box;
12 using hpp::fcl::collide;
16 using hpp::fcl::FCL_REAL;
18 using hpp::fcl::Vec3f;
19 
20 BOOST_AUTO_TEST_CASE(box_box_collision) {
21  // Define boxes
22  Box shape1(1, 1, 1);
23  Box shape2(1, 1, 1);
24 
25  // Define transforms
26  Transform3f T1 = Transform3f::Identity();
27  Transform3f T2 = Transform3f::Identity();
28 
29  // Compute collision
30  CollisionRequest req;
31  req.enable_cached_gjk_guess = true;
32  req.distance_upper_bound = 1e-6;
34  ComputeCollision collide_functor(&shape1, &shape2);
35 
36  T1.setTranslation(Vec3f(0, 0, 0));
37  res.clear();
38  BOOST_CHECK(collide(&shape1, T1, &shape2, T2, req, res) == true);
39  res.clear();
40  BOOST_CHECK(collide_functor(T1, T2, req, res) == true);
41 
42  T1.setTranslation(Vec3f(2, 0, 0));
43  res.clear();
44  BOOST_CHECK(collide(&shape1, T1, &shape2, T2, req, res) == false);
45  res.clear();
46  BOOST_CHECK(collide_functor(T1, T2, req, res) == false);
47 }
Simple transform class used locally by InterpMotion.
Definition: transform.h:54
void setTranslation(const Eigen::MatrixBase< Derived > &T_)
set transform from translation
Definition: transform.h:142
FCL_REAL distance_upper_bound
Distance above which GJK solver makes an early stopping. GJK stops searching for the closest points w...
bool enable_cached_gjk_guess
whether enable gjk initial guess Use gjk_initial_guess instead
request to the collision algorithm
void clear()
clear the results obtained
double FCL_REAL
Definition: data_types.h:65
This class reduces the cost of identifying the geometry pair. This is mostly useful for repeated shap...
Definition: collision.h:103
Center at zero point, axis aligned box.
res
HPP_FCL_DLLAPI std::size_t collide(const CollisionObject *o1, const CollisionObject *o2, const CollisionRequest &request, CollisionResult &result)
Main collision interface: given two collision objects, and the requirements for contacts, including num of max contacts, whether perform exhaustive collision (i.e., returning returning all the contact points), whether return detailed contact information (i.e., normal, contact point, depth; otherwise only contact primitive id is returned), this function performs the collision between them. Return value is the number of contacts generated between the two objects.
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:66
BOOST_AUTO_TEST_CASE(box_box_collision)


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:00