Repository navigation
Drop border detail the machine cannot act on before decomposing - #253
Gonzalo-Mier merged 6 commits into
Conversation
A decomposition splits a field wherever its border turns back on itself. A digitised border does that on details of a few centimetres, so the field comes back cut into pieces that exist only in the survey -- ee_field_130 gives sixteen where four of them are noise, and each one pays for a headland it does not need. The function added here hands the cells straight back, so the test is red on the count. The first expectation, that the raw border gives sixteen, already passes and has to keep passing.
Simplify the border to 0.6 of the coverage width first, so the split lines follow the shape of the field rather than the noise on it. ee_field_130 goes from sixteen cells to twelve. The share is measured, not assumed: over 305 fields and two robots it is where the decomposition returns 30% fewer cells, no piece lands outside the field it came from, and the area moves by less than a tenth of a percent. Below it noise survives; well above it splits the shape genuinely asks for start merging.
The doc comment said the same thing twice; the measured numbers live in the changelog and in the source, not in the header.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Only minor documentation percentage corrections remain; no blocking issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Adds robot-aware border simplification before decomposition to remove insignificant survey detail while preserving existing behavior.
Changes:
- Adds
simplifyForDecompositionto C++ and Python APIs. - Adds C++ and Python regression tests.
- Documents the API and non-clipping behavior.
| File | Summary |
|---|---|
tests/python/decomposition/decomposition_base_test.py |
Tests Python API behavior and area preservation. |
tests/cpp/decomposition/boustrophedon_decomp_test.cpp |
Tests reduced decomposition splits. |
src/fields2cover/decomposition/decomposition_base.cpp |
Implements threshold-based border simplification. |
include/fields2cover/decomposition/decomposition_base.h |
Declares and documents the public API. |
CHANGELOG.md |
Documents the new feature. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // the field it came from, and the area moves by less than a tenth of a | ||
| // percent. Taking less leaves noise behind; taking much more starts merging | ||
| // splits the shape of the field genuinely asks for. | ||
| constexpr double kBorderDetailShare = 0.6; |
There was a problem hiding this comment.
This value should be part of the class or argument of the function used. You can add it as last argument and give it a default value if you want, but never here.
There was a problem hiding this comment.
Actually, I chose this value based on the results I obtained by calculating it for 300 scenarios using approximately 20 different values (for a total of 6,000 scenarios), but it makes sense to make it optional.
There was a problem hiding this comment.
I understand the way you picked the value, but I dont like having random constants in the cpp files.
There was a problem hiding this comment.
Done in c5ad294 — the constant is gone from the .cpp. It is now the last argument, double detail_share = 0.6, and the measurement behind the default moved into the parameter's doc comment in the header.
It was a constant inside the function. The measured 0.6 stays the default, so a two-argument call gives the same cells as before.
Removed extra comments about testing in the documentation
|
Thank you @u33549!! |
A decomposition splits a field wherever its border turns back on itself. A
digitised border does that on details of a few centimetres -- far below
anything the machine can act on -- so the field comes back cut into pieces that
exist only in the survey, each one paying for a headland it does not need.
f2c::decomp::simplifyForDecomposition(cells, robot)removes border detailbelow 0.6 of the robot's coverage width before the field is decomposed.
ee_field_130goes from sixteen cells to twelve.Measured over 305 real fields x two robot profiles (2.5 m and 6 m coverage,
610 field/robot pairs):
up to 1.6 of the coverage width
On a 50-field subset with the full coverage metric (59 pairs, mainland minus
the area a turn overruns): the constant-width headland gains +15,646 m² and
the classic
2R + w/2headland +9,364 m². The gain is largest for thesimplest method, which is what you would expect if it is removing work nobody
should have been doing.
The threshold is measured rather than assumed. Below it noise survives; well
above it the splits the shape genuinely asks for start merging -- at 1.2 of the
coverage width a nine-cell field collapses to one.
decompose()is untouched. It still returns cells whose area equals its input,so nothing changes for callers that do not ask for the simplification.
One deliberate limitation: the result is not clipped to the input.
Simplifying moves the border both ways, so a point can land outside; the
function expects ground that is already inside the field -- a mainland from a
headland generator, not the raw boundary -- and says so in its doc comment.
Clipping would guarantee containment but costs most of the benefit: on the same
50 fields the cell reduction drops from 33% to 13% and the area loss grows
tenfold.