35 #define BOOST_TEST_MODULE FCL_DISTANCE_LOWER_BOUND 36 #include <boost/test/included/unit_test.hpp> 37 #include <boost/filesystem.hpp> 47 #include "fcl_resources/config.h" 58 using hpp::fcl::shared_ptr;
117 std::vector<Vec3f>
p1, p2;
118 std::vector<Triangle> t1, t2;
121 loadOBJFile((path /
"env.obj").
string().c_str(), p1, t1);
122 loadOBJFile((path /
"rob.obj").
string().c_str(), p2, t2);
128 m1->addSubModel(p1, t1);
132 m2->addSubModel(p2, t2);
135 std::vector<Transform3f> transforms;
142 for (std::size_t i = 0; i < transforms.size(); ++i) {
144 bool col1, col2, col3;
148 std::cout <<
"col1 = " << col1 <<
", col2 = " << col2 <<
", col3 = " << col3
150 std::cout <<
"distance lower bound = " << distanceLowerBound << std::endl;
151 std::cout <<
"distance = " << distance << std::endl;
152 BOOST_CHECK(col1 == col3);
154 BOOST_CHECK_MESSAGE(distanceLowerBound <= distance,
155 "distance = " << distance <<
", lower bound = " 156 << distanceLowerBound);
170 std::vector<Transform3f> transforms;
172 const std::size_t n = 1000;
180 BOOST_CHECK(col1 == col2);
181 BOOST_CHECK(distanceLowerBound <= distance);
183 for (std::size_t i = 0; i < transforms.size(); ++i) {
188 col2 =
testDistance(transforms[i], sphere, box, distance);
189 BOOST_CHECK(col1 == col2);
191 BOOST_CHECK_MESSAGE(distanceLowerBound <= distance,
192 "distance = " << distance <<
", lower bound = " 193 << distanceLowerBound);
207 std::vector<Transform3f> transforms;
209 const std::size_t n = 1000;
217 BOOST_CHECK(col1 == col2);
218 BOOST_CHECK(distanceLowerBound <= distance);
220 for (std::size_t i = 0; i < transforms.size(); ++i) {
225 col2 =
testDistance(transforms[i], sphere1, sphere2, distance);
226 BOOST_CHECK(col1 == col2);
228 BOOST_CHECK_MESSAGE(distanceLowerBound <= distance,
229 "distance = " << distance <<
", lower bound = " 230 << distanceLowerBound);
236 std::vector<Vec3f>
p1;
237 std::vector<Triangle> t1;
240 loadOBJFile((path /
"env.obj").
string().c_str(), p1, t1);
243 shared_ptr<hpp::fcl::Box> m2(
new hpp::fcl::Box(500, 200, 150));
246 m1->addSubModel(p1, t1);
249 std::vector<Transform3f> transforms;
256 for (std::size_t i = 0; i < transforms.size(); ++i) {
261 BOOST_CHECK(col1 == col2);
263 BOOST_CHECK_MESSAGE(distanceLowerBound <= distance,
264 "distance = " << distance <<
", lower bound = " 265 << distanceLowerBound);
request to the distance computation
void loadOBJFile(const char *filename, std::vector< Vec3f > &points, std::vector< Triangle > &triangles)
Load an obj mesh file.
void generateRandomTransforms(FCL_REAL extents[6], std::vector< Transform3f > &transforms, std::size_t n)
Generate n random transforms whose translations are constrained by extents.
FCL_REAL distance_lower_bound
request to the collision algorithm
HPP_FCL_DLLAPI FCL_REAL distance(const Matrix3f &R0, const Vec3f &T0, const kIOS &b1, const kIOS &b2, Vec3f *P=NULL, Vec3f *Q=NULL)
Approximate distance between two kIOS bounding volumes.
FCL_REAL min_distance
minimum distance between two objects. if two objects are in collision, min_distance <= 0...
Center at zero point, axis aligned box.
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Center at zero point sphere.
bool testDistanceLowerBound(const Transform3f &tf, const CollisionGeometryPtr_t &m1, const CollisionGeometryPtr_t &m2, FCL_REAL &distance)
Triangle with 3 indices for points.
bool enable_distance_lower_bound
Whether a lower bound on distance is returned when objects are disjoint.
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.
shared_ptr< CollisionGeometry > CollisionGeometryPtr_t
BOOST_AUTO_TEST_CASE(mesh_mesh)
bool isCollision() const
return binary collision result
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
the object for collision or distance computation, contains the geometry and the transform information...
bool testCollide(const Transform3f &tf, const CollisionGeometryPtr_t &m1, const CollisionGeometryPtr_t &m2)
double distance(const std::vector< Transform3f > &tf, const BVHModel< BV > &m1, const BVHModel< BV > &m2, bool verbose)
bool testDistance(const Transform3f &tf, const CollisionGeometryPtr_t &m1, const CollisionGeometryPtr_t &m2, FCL_REAL &distance)