Commit c676c3ab authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

Add a test in test_fcl_box_box_distance.

parent 384ccbd2
......@@ -89,99 +89,41 @@ BOOST_AUTO_TEST_CASE(distance_box_box_1)
BOOST_CHECK_CLOSE (p2 [2], 4, 1e-6);
}
#if 0
BOOST_AUTO_TEST_CASE(distance_capsulecapsule_transformXY)
BOOST_AUTO_TEST_CASE(distance_box_box_2)
{
CollisionGeometryPtr_t s1 (new Capsule (5, 10));
CollisionGeometryPtr_t s2 (new Capsule (5, 10));
Transform3f tf1;
Transform3f tf2 (Vec3f(20, 20,0));
CollisionObject o1 (s1, tf1);
CollisionObject o2 (s2, tf2);
// Enable computation of nearest points
DistanceRequest distanceRequest (true);
DistanceResult distanceResult;
distance (&o1, &o2, distanceRequest, distanceResult);
std::cerr << "Applied translation on two capsules";
std::cerr << " T1 = " << tf1.getTranslation()
<< ", T2 = " << tf2.getTranslation() << std::endl;
std::cerr << "Closest points: p1 = " << distanceResult.nearest_points [0]
<< ", p2 = " << distanceResult.nearest_points [1]
<< ", distance = " << distanceResult.min_distance << std::endl;
FCL_REAL expected = sqrt(800) - 10;
BOOST_CHECK_CLOSE(distanceResult.min_distance, expected, 1e-6);
}
BOOST_AUTO_TEST_CASE(distance_capsulecapsule_transformZ)
{
CollisionGeometryPtr_t s1 (new Capsule (5, 10));
CollisionGeometryPtr_t s2 (new Capsule (5, 10));
CollisionGeometryPtr_t s1 (new Box (6, 10, 2));
CollisionGeometryPtr_t s2 (new Box (2, 2, 2));
static double pi = M_PI;
Transform3f tf1;
Transform3f tf2 (Vec3f(0,0,20.1));
Transform3f tf2 (Quaternion3f (cos (pi/8), sin(pi/8)/sqrt(3),
sin(pi/8)/sqrt(3), sin(pi/8)/sqrt(3)),
Vec3f(0, 0, 10));
CollisionObject o1 (s1, tf1);
CollisionObject o2 (s2, tf2);
// Enable computation of nearest points
DistanceRequest distanceRequest (true);
DistanceRequest distanceRequest (true, 0, 0, GST_INDEP);
DistanceResult distanceResult;
distance (&o1, &o2, distanceRequest, distanceResult);
std::cerr << "Applied translation on two capsules";
std::cerr << "Applied translation on two boxes";
std::cerr << " T1 = " << tf1.getTranslation()
<< ", T2 = " << tf2.getTranslation() << std::endl;
std::cerr << "Closest points: p1 = " << distanceResult.nearest_points [0]
<< ", p2 = " << distanceResult.nearest_points [1]
<< ", distance = " << distanceResult.min_distance << std::endl;
BOOST_CHECK_CLOSE(distanceResult.min_distance, 0.1, 1e-6);
}
BOOST_AUTO_TEST_CASE(distance_capsulecapsule_transformZ2)
{
CollisionGeometryPtr_t s1 (new Capsule (5, 10));
CollisionGeometryPtr_t s2 (new Capsule (5, 10));
Transform3f tf1;
Transform3f tf2 (Quaternion3f (sqrt (2)/2, 0, sqrt (2)/2, 0),
Vec3f(0,0,25.1));
CollisionObject o1 (s1, tf1);
CollisionObject o2 (s2, tf2);
// Enable computation of nearest points
DistanceRequest distanceRequest (true);
DistanceResult distanceResult;
distance (&o1, &o2, distanceRequest, distanceResult);
std::cerr << "Applied rotation and translation on two capsules" << std::endl;
std::cerr << "R1 = " << tf1.getRotation ()
<< ", T1 = " << tf1.getTranslation() << std::endl
<< "R2 = " << tf2.getRotation ()
<< ", T2 = " << tf2.getTranslation() << std::endl;
std::cerr << "Closest points: p1 = " << distanceResult.nearest_points [0]
<< ", p2 = " << distanceResult.nearest_points [1]
<< ", distance = " << distanceResult.min_distance << std::endl;
const Vec3f& p1 = distanceResult.nearest_points [0];
const Vec3f& p2 = distanceResult.nearest_points [1];
double distance = -1.62123444 + 10 - 1;
BOOST_CHECK_CLOSE(distanceResult.min_distance, distance, 1e-4);
BOOST_CHECK_CLOSE(distanceResult.min_distance, 10.1, 1e-6);
CHECK_CLOSE_TO_0 (p1 [0], 1e-4);
CHECK_CLOSE_TO_0 (p1 [1], 1e-4);
BOOST_CHECK_CLOSE (p1 [2], 10, 1e-4);
CHECK_CLOSE_TO_0 (p2 [0], 1e-4);
CHECK_CLOSE_TO_0 (p2 [1], 1e-4);
BOOST_CHECK_CLOSE (p2 [2], 20.1, 1e-4);
BOOST_CHECK_CLOSE (p1 [0], 0.60947571, 1e-4);
BOOST_CHECK_CLOSE (p1 [1], 0.01175873, 1e-4);
BOOST_CHECK_CLOSE (p1 [2], 1, 1e-6);
BOOST_CHECK_CLOSE (p2 [0], 0.60947571, 1e-4);
BOOST_CHECK_CLOSE (p2 [1], 0.01175873, 1e-4);
BOOST_CHECK_CLOSE (p2 [2], -1.62123444 + 10, 1e-4);
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment