Repository navigation
Route decomposed fields along headlands - #119
SteveMacenski merged 5 commits into
Conversation
A sub-cell narrower than ~2x the headland width collapsed to an empty geometry under the inward buffer, and getGeometry(0) then threw instead of being handled. Buffer each sub-cell directly, skip empty results, and keep every polygon a split may produce; throw a clear error only if every cell collapses. Adds regression tests for both cases.
Decomposed fields applied the headland per sub-cell first, isolating each cell; routes then bridged cells with straight lines cutting across the field. Shrink the field to a travel ring first, decompose that, then shrink each sub-cell again for its swaths, so connections follow the shared headland instead. TSP planning uses a single global genRoute for small fields and falls back to per-cell TSP above a swath-count cap, avoiding an all-pairs OOM. Non-TSP route modes are rejected with decomposition, since they only support a single cell.
|
In the next PR, or once everything is complete, can I update opennav_coverage_demo to showcase the new system? I tried symbols like a balloon or a navigation icon, but they didn't look very good. I'll probably try a simpler letter or shape. |
|
It also works well with simple shapes, but as the shape becomes more complex, for example, as gaps are added or the concavity increases, it can sometimes produce different results. Once the integration is complete, I’ll try to set aside some time specifically for making improvements. |
|
|
||
| // Above this many total swaths, TspRouteMethod falls back to per-cell TSP to avoid | ||
| // F2C's O(N^2) all-pairs path matrix that OOMs on large decompositions. | ||
| static constexpr size_t kMaxSwathsForGlobalRoute = 300; |
There was a problem hiding this comment.
How did you determine this value and what computer did you test it against that caused memory issues?
There was a problem hiding this comment.
Honestly the value is approximate — I hit an actual out-of-memory crash (blue-screen) while testing a very large field on my own machine, so I set a conservative cap below where that happened rather than a precisely-tuned number. The root cause is algorithmic: F2C v2.0.0's RoutePlannerBase materializes the all-pairs shortest-path matrix (~N² with N ≈ 4× total swaths), so it blows up on large decompositions regardless of the machine. However, it might be helpful to make this parametric.
This is fixed upstream in F2C commit 0ce7fcc, but that landed on main after the v2.0.0 release and we depend on the released v2, so we can't pull it in yet.
There was a problem hiding this comment.
OK. How about stating a warning in the docs instead of setting an arbitrary limit?
There was a problem hiding this comment.
But wouldn’t that eliminate its usability in these large areas? Wouldn’t it make more sense to convert it to a parameter and add a warning?
Also, the per-cell fallback isn't only a theoretical guard, it's what keeps large decomposed fields returning a valid (if less-optimal) route instead of crashing. Concretely, testTSPDecompHeadlandPath already exercises it: test_field.xml has enough swaths to cross the threshold, so removing the fallback would send that test through a single genRoute over the whole swath set ,exactly the case that risks the OOM/timeout in CI.
There was a problem hiding this comment.
OK - parameterize then :-)
Sure! That'd be great. Maybe mention some of the new features too in the readme that this adds if there's a logical place for it |
default_max_swaths_for_global_route replaces the hard-coded threshold, with a note on when to tune it; drop the redundant show_log argument comments.
|
There are probably just a few PRs left before this development is complete. After that, I’ll entegrate to other distros. I also asked the F2C developer to add commit 0ce7fcc to v2.0.0 |
Summary
Completes decomposition-with-route support: routes decomposed (multi-cell)
fields along their headlands so inter-cell connections follow the shared
headland, and fixes a multi-cell headland crash. Builds on #112, #113, #117.
Changes
Route decomposed fields along headlands
each cell a disconnected island; per-cell TSP then stitched routes with
straight-line bridges that cut across the field. Non-TSP modes flattened the
multi-cell swaths into a single-cell orderer, fanning connections across the field.
sub-cell again for the swath area.
genRouteis fed the border-sharing travelcells so inter-cell connections follow the headlands.
generateRouteTSPtakes separatetravel_cellsandswath_cells: small fieldsuse a single global
genRoute; large fields (swath count above a cap) fall backto per-cell TSP to avoid the O(N²) all-pairs OOM.
INVALID_MODE_SETerror.Fix multi-cell headland crash on collapsed sub-cells
generateHeadlands(F2CCells)overload applied the headland toeach sub-cell through the single-
Fieldoverload (ending in.getGeometry(0)).ConstHLis a negative buffer, so a sub-cell narrower than ~2×width collapses toempty and
getGeometry(0)threw "Geometry does not contain point 0" ondecomposed fields.
resulting polygon (a negative buffer may split one cell into several), and throw
a clear
CoverageExceptionif every sub-cell collapses. Generator/widthresolution extracted into a shared
resolveGenerator()helper.