Skip to content

Commit 6af5dc8

Browse files
committed
Catch zero cost.
1 parent e86369b commit 6af5dc8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

polygon_coverage_solvers/include/polygon_coverage_solvers/impl/graph_base_impl.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,15 @@ GraphBase<NodeProperty, EdgeProperty>::getAdjacencyMatrix() const {
342342
}
343343
}
344344
sort(sorted_cost.begin(), sorted_cost.end());
345-
const double equality = 0.000001; // Min. considered cost difference.
345+
const double equality = 0.000001; // Min. considered cost difference.
346346
auto min_diff = sorted_cost.back();
347+
if (sorted_cost.back() == 0.0) {
348+
ROS_ERROR("Adjacency matrix invalid. Greatest cost is 0.0.");
349+
min_diff = std::numeric_limits<double>::max();
350+
}
347351
for (size_t i = 0; i < sorted_cost.size() - 1; i++) {
348352
auto diff = std::fabs(sorted_cost[i + 1] - sorted_cost[i]);
349-
if (diff > equality && diff < min_diff)
350-
min_diff = diff;
353+
if (diff > equality && diff < min_diff) min_diff = diff;
351354
}
352355

353356
// Only scale with min_diff if this does not blow up the cost.

0 commit comments

Comments
 (0)