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

Incorrect nearest points when using distance(...) #275

Open
pierrefranklin opened this issue Apr 4, 2018 · 2 comments
Open

Incorrect nearest points when using distance(...) #275

pierrefranklin opened this issue Apr 4, 2018 · 2 comments

Comments

@pierrefranklin
Copy link

I get incorrect nearest points when I use the following code:

#include <fcl/narrowphase/distance.h>

using namespace fcl;
using S = double;

int main(){

  Sphere<S> s1{20};
  Sphere<S> s2{10};

  Transform3<S> tf1{Transform3<S>::Identity()};
  Transform3<S> tf2{Transform3<S>::Identity()};

  DistanceRequest<S> request;
  request.enable_signed_distance = true;
  request.enable_nearest_points = true;
  request.gjk_solver_type = GST_LIBCCD;

  DistanceResult<S> result;

  bool res{false};

  // Expecting distance to be 10
  result.clear();
  tf2.translation() = Vector3<S>(0, 40, 0);
  res = distance(&s1, tf1, &s2, tf2, request, result);

  std::cout<<"fcl_result = "<<result.min_distance<<std::endl;
  std::cout<<"fcl_result point 1 = "<<result.nearest_points[0]<<std::endl;
  std::cout<<"fcl_result point 2 = "<<result.nearest_points[1]<<std::endl;

  return 0;

}

The output of the executable is

fcl_result = 25
fcl_result point 1 =       0
27.3333
      0
fcl_result point 2 =        0
-13.6667
       0

This is copied almost verbatim from the tests, specifically the test_distance_spheresphere(...) function in test_fcl_signed_distance. The only difference is that tf2.translation() = Vector3<S>(0, 40, 0); instead of tf2.translation() = Vector3<S>( 40, 0, 0); (ie X and Y are flipped).

This also happens with using the Z coordinate, and with other primitives.

@hongkai-dai
Copy link
Contributor

I believe now the error should be fixed after #305. I ran your test, and here is the result

fcl_result = 10
fcl_result point 1 = -0.00055429
         20
          0
fcl_result point 2 = 0.000277145
        -10
          0

@sherm1
Copy link
Member

sherm1 commented Jul 6, 2018

@pierrefranklin can you verify that the problem you observed is now fixed, and if so close this issue?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants