Skip to content

Commit e396499

Browse files
authored
fix: AORRTC segfault when no nearest neighbors are within distance threshold (#79)
* fixes aorrtc segfault when no nearest neighbors are within distance threshold * tweak comment * ran clang-format * format attempt
1 parent 2573e11 commit e396499

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/impl/vamp/planning/aorrtc.hh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ namespace vamp::planning
6969
auto temp_node = NNNode{0, cost, c};
7070
nn->nearestR(temp_node, NNNode::distance(temp_node, root), near_list);
7171

72+
// Explicitly handle case where no neighbors are within r distance.
73+
if (near_list.empty())
74+
{
75+
return {root, c.distance(root.array)};
76+
}
77+
7278
const auto *new_nearest_node = &near_list[0];
7379
float new_nearest_distance = c.distance(new_nearest_node->array);
7480

0 commit comments

Comments
 (0)