Skip to content

Commit

Permalink
fix missing nearest points in Octree<->Mesh distance result (#427)
Browse files Browse the repository at this point in the history
* fix missing nearest points in Octree<->Mesh distance result

* Extend test_fcl_octomap_distance, check nearest_points

Co-authored-by: Alberto Marnetto <58592261+AlbertoMarnetto-Work@users.noreply.github.com>
  • Loading branch information
2 people authored and SeanCurtis-TRI committed Jan 14, 2020
1 parent 6aeb7a1 commit 79b4d4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ bool OcTreeSolver<NarrowPhaseSolver>::OcTreeMeshDistanceRecurse(const OcTree<S>*
Vector3<S> closest_p1, closest_p2;
solver->shapeTriangleDistance(box, box_tf, p1, p2, p3, tf2, &dist, &closest_p1, &closest_p2);

dresult->update(dist, tree1, tree2, root1 - tree1->getRoot(), primitive_id);
dresult->update(dist, tree1, tree2, root1 - tree1->getRoot(), primitive_id, closest_p1, closest_p2);

return drequest->isSatisfied(*dresult);
}
Expand Down
8 changes: 8 additions & 0 deletions test/test_fcl_octomap_distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ void octomap_distance_test_BVH(std::size_t n, double resolution)
CollisionObject<S> obj1(m1_ptr, tf);
CollisionObject<S> obj2(tree_ptr, tf);
test::DistanceData<S> cdata;
cdata.request.enable_nearest_points = true;
S dist1 = std::numeric_limits<S>::max();
test::defaultDistanceFunction(&obj1, &obj2, &cdata, dist1);

Expand All @@ -219,6 +220,13 @@ void octomap_distance_test_BVH(std::size_t n, double resolution)

std::cout << dist1 << " " << dist2 << std::endl;
EXPECT_TRUE(std::abs(dist1 - dist2) < 0.001);

// Check that the nearest points are consistent with the distance
// Note that we cannot compare the result with the "boxes" approximation,
// since the problem is ill-posed (i.e. the nearest points may differ widely
// for slightly different geometries)
Vector3<S> nearestPointDistance = cdata.result.nearest_points[0] - cdata.result.nearest_points[1];
EXPECT_NEAR(nearestPointDistance.norm(), dist1, 0.001);
}
}

Expand Down

0 comments on commit 79b4d4c

Please sign in to comment.