41 #include <gtest/gtest.h> 42 #include <Eigen/Dense> 58 bool enable_nearest_points,
59 bool enable_signed_distance,
68 X_FA.translation() = p_FA;
69 X_FB.translation() = p_FB;
76 using CollisionGeometryPtr_t = std::shared_ptr<fcl::CollisionGeometry<S>>;
77 CollisionGeometryPtr_t sphere_geometry_1(
new fcl::Sphere<S>(radius1));
78 CollisionGeometryPtr_t sphere_geometry_2(
new fcl::Sphere<S>(radius2));
82 const S min_distance =
fcl::distance(&sphere_1, &sphere_2, request, *result);
99 bool enable_nearest_points,
100 bool enable_signed_distance,
101 S min_distance_expected,
105 const S min_distance = ComputeSphereSphereDistance<S>(
107 enable_nearest_points, enable_signed_distance, &result);
108 EXPECT_NEAR(min_distance, min_distance_expected, tol);
109 EXPECT_NEAR(result.
min_distance, min_distance_expected, tol);
114 template <
typename S>
118 : sphere1(m_sphere1), sphere2(m_sphere2) {
120 (sphere1.p_FC - sphere2.p_FC).norm() - sphere1.radius - sphere2.radius;
122 p_WP1 = sphere1.p_FC + AB * -sphere1.radius;
123 p_WP2 = sphere2.p_FC + AB * sphere2.radius;
134 template <
typename S>
136 std::vector<SphereSpecification<S>> spheres;
142 for (
int i = 0; i < static_cast<int>(spheres.size()); ++i) {
143 for (
int j = i + 1; j < static_cast<int>(spheres.size()); ++j) {
145 bool enable_signed_distance =
true;
146 CheckSphereToSphereDistance<S>(
147 spheres[i], spheres[j], solver_type,
true, enable_signed_distance,
149 sphere_sphere_distance.
p_WP2, tol);
153 CheckSphereToSphereDistance<S>(
154 spheres[j], spheres[i], solver_type,
true, enable_signed_distance,
156 sphere_sphere_distance.
p_WP1, tol);
158 enable_signed_distance =
false;
159 CheckSphereToSphereDistance<S>(
160 spheres[i], spheres[j], solver_type,
true, enable_signed_distance,
162 sphere_sphere_distance.
p_WP2, tol);
166 CheckSphereToSphereDistance<S>(
167 spheres[j], spheres[i], solver_type,
true, enable_signed_distance,
169 sphere_sphere_distance.
p_WP1, tol);
191 int main(
int argc,
char* argv[]) {
192 ::testing::InitGoogleTest(&argc, argv);
193 return RUN_ALL_TESTS();
void TestSeparatingSpheres(S tol, fcl::GJKSolverType solver_type)
S min_distance
Minimum distance between two objects.
::testing::AssertionResult CompareMatrices(const Eigen::MatrixBase< DerivedA > &m1, const Eigen::MatrixBase< DerivedB > &m2, double tolerance=0.0, MatrixCompareType compare_type=MatrixCompareType::absolute)
Eigen::Transform< S, 3, Eigen::Isometry > Transform3
GTEST_TEST(FCL_SPHERE_SPHERE, Separating_Spheres_INDEP)
SphereSphereDistance(const SphereSpecification< S > &m_sphere1, const SphereSpecification< S > &m_sphere2)
SphereSpecification(S m_radius, const fcl::Vector3< S > &p_FC_)
S distance(const Eigen::MatrixBase< DerivedA > &R0, const Eigen::MatrixBase< DerivedB > &T0, const kIOS< S > &b1, const kIOS< S > &b2, Vector3< S > *P, Vector3< S > *Q)
Approximate distance between two kIOS bounding volumes.
int main(int argc, char *argv[])
#define EXPECT_NEAR(a, b, prec)
Eigen::Matrix< S, 3, 1 > Vector3
void CheckSphereToSphereDistance(const SphereSpecification< S > &sphere1, const SphereSpecification< S > &sphere2, fcl::GJKSolverType solver_type, bool enable_nearest_points, bool enable_signed_distance, S min_distance_expected, const fcl::Vector3< S > &p1_expected, const fcl::Vector3< S > &p2_expected, S tol)
bool enable_nearest_points
whether to return the nearest points
GJKSolverType gjk_solver_type
narrow phase solver type
S ComputeSphereSphereDistance(S radius1, S radius2, const fcl::Vector3< S > &p_FA, const fcl::Vector3< S > &p_FB, fcl::GJKSolverType solver_type, bool enable_nearest_points, bool enable_signed_distance, fcl::DistanceResult< S > *result)
the object for collision or distance computation, contains the geometry and the transform information...
SphereSpecification< S > sphere2
SphereSpecification< S > sphere1
bool enable_signed_distance
Whether to compute exact negative distance.
Vector3< S > nearest_points[2]
Nearest points in the world coordinates.
Center at zero point sphere.
request to the distance computation
#define EXPECT_TRUE(args)
GJKSolverType
Type of narrow phase GJK solver.