Skip to content

Use Fields2Cover v2.1.1 for the pieces it now provides - #162

Merged
SteveMacenski merged 8 commits into
open-navigation:mainfrom
u33549:use-fields2cover-2.1.1
Nov 23, 2026
Merged

SteveMacenski merged 8 commits into
open-navigation:mainfrom
u33549:use-fields2cover-2.1.1

Conversation

@u33549

@u33549 u33549 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Several things this package implemented itself have since landed in Fields2Cover (tracked in Fields2Cover/Fields2Cover#231). This PR moves the pin to Fields2Cover v2.1.1 and drops the local copies that are now redundant. Two small bugs found along the way are fixed in their own commits. Route ordering and connection handling are not touched here; they follow once the remaining Fields2Cover route work is released.

Changes

Commit Local code it removes (added in) Replaced by
Pin Fields2Cover to v2.1.1 v2.0.0 pin in .github/deps.repos (#110) Fields2Cover v2.1.1
Drop the unused multi-cell headland overload HeadlandGenerator::generateHeadlands(F2CCells, …) (#113), no callers since the headland-first rework in #119 –
Let Fields2Cover densify headland passes util::discretizeSwathLike (#141) Path::discretizeSwath, which now splits HL_SWATH too (Fields2Cover/Fields2Cover#234)
Carve the inter-cell corridor with Fields2Cover shared-border carving in generateHeadlandsBetweenCells (#135) hg::CorridorHL (Fields2Cover/Fields2Cover#243, Fields2Cover/Fields2Cover#248)
Drop the sliver filter Fields2Cover no longer needs kMinCellArea filter (#135) degenerate-polygon fix in Fields2Cover/Fields2Cover#243; CorridorHL drops zero-width pieces
Remove the unused default_max_swaths_for_global_route parameter parameter (#119), no effect since the per-cell TSP in #137 –

Net: 12 files, +81 / −208 (code +12 / −132, tests +64 / −71).

Bug fixes

  • coverage_path.swaths ends. With Fields2Cover v2 a straight swath is a single path state, but the message took the end from that state's start point, so every swath came back with start == end. The end now comes from PathState::atEnd().
  • GPS nav_path density. The path was converted to the GPS frame before being densified, so the step (in meters) was applied to lengths in degrees and swaths were not split. It is now densified in the field frame first.

Both have a regression test that fails without the fix.

Behaviour change: route_headland_width

The corridor between decomposed cells is now exactly route_headland_width wide and is carved from the smaller of the two cells. Before (#135), a cell was carved only when one of its edges lay entirely on the neighbour's border, so a corridor could come out twice as wide (both sides carved) or be missing (border shared only in part). Across the decomposed scenarios below this raises coverage by 0.5–5 points and shortens travel by up to 49 %.

Removed parameter

default_max_swaths_for_global_route (added in #119) has had no effect since #137 replaced the global genRoute fallback with a per-cell solve, so it is removed.

Testing

  • colcon test for opennav_coverage_msgs, opennav_coverage and opennav_row_coverage: 274 tests, 0 failures. 3 removed tests covered removed code; 2 new tests cover the bug fixes.
  • Each commit was run on 30 fixed scenarios and compared with the previous commit. The scenarios cover rectangles, voids, concave L/U/T/E fields, decomposition with and without headland, all route modes, start pose, Reeds-Shepp, GPS and row coverage.
    • The commits that only swap in Fields2Cover calls produce bit-identical plans.
    • The corridor commit changes decomposed fields as described above.
  • Planning time on 8 heavy scenarios (median of 3 runs) stays within run-to-run noise (about ±10 %) of the current pin; memory unchanged.

Known issue (Fields2Cover side)

generateBestSwaths can return zero-length swaths in the zero-width cells that trapezoidal decomposition leaves behind. That adds stray turns on decomposed fields without a headland. It is independent of this PR and is being fixed upstream.

Copilot AI balanced review requested due to automatic review settings November 21, 2026 19:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@agentscanapp

agentscanapp Bot commented Nov 21, 2026

Copy link
Copy Markdown

Insufficient data

Not enough activity yet to make a reliable assessment.

View full analysis →

This is an automated analysis by AgentScan

Fields2Cover v2.1.1 carries the fixes and APIs this package used to work
around: HL_SWATH densification, the corridor headland and the
degenerate-polygon guard.

Signed-off-by: u33549 <[email protected]>
The server only calls the Field overload; the F2CCells one had no
callers left after the headland-first decomposition rework.

Signed-off-by: u33549 <[email protected]>
Path::discretizeSwath now splits HL_SWATH states as well, so the local
copy that did the same is no longer needed. The step guard stays at the
call site since Fields2Cover does not clamp a zero step.

Signed-off-by: u33549 <[email protected]>
CorridorHL finds the borders cells really share and carves the corridor
from the smaller cell. route_headland_width is now the total corridor
width; the previous code could carve it from both cells, or miss a
partially shared border.

Signed-off-by: u33549 <[email protected]>
CorridorHL already removes the zero-width pieces carving leaves, and the
degenerate-polygon crash the filter guarded against is fixed upstream.

Signed-off-by: u33549 <[email protected]>
It has had no effect since multi-cell TSP routing moved to a per-cell
solve; the threshold it set is no longer read.

Signed-off-by: u33549 <[email protected]>
With Fields2Cover v2 a straight swath is a single path state, so taking
the end from that state's start point gave every swath start == end.
Use PathState::atEnd() instead.

Signed-off-by: u33549 <[email protected]>
The densification step is in meters, but it ran after the path was
converted to the GPS frame, so swath lengths were in degrees and no
state was ever split.

Signed-off-by: u33549 <[email protected]>
@SteveMacenski
SteveMacenski merged commit 449e149 into open-navigation:main Nov 23, 2026
7 of 8 checks passed
SteveMacenski pushed a commit that referenced this pull request Nov 27, 2026
* Pin Fields2Cover to v2.1.1 for the upstreamed fixes

Fields2Cover v2.1.1 carries the fixes and APIs this package used to work
around: HL_SWATH densification, the corridor headland and the
degenerate-polygon guard.

(cherry picked from commit 2ef1796, part of #162)
Signed-off-by: u33549 <[email protected]>

* Drop the unused multi-cell headland overload

The server only calls the Field overload; the F2CCells one had no
callers left after the headland-first decomposition rework.

(cherry picked from commit 93915e2, part of #162)
Signed-off-by: u33549 <[email protected]>

* Let Fields2Cover densify headland passes

Path::discretizeSwath now splits HL_SWATH states as well, so the local
copy that did the same is no longer needed. The step guard stays at the
call site since Fields2Cover does not clamp a zero step.

(cherry picked from commit 195b002, part of #162)
Signed-off-by: u33549 <[email protected]>

* Carve the inter-cell corridor with Fields2Cover

CorridorHL finds the borders cells really share and carves the corridor
from the smaller cell. route_headland_width is now the total corridor
width; the previous code could carve it from both cells, or miss a
partially shared border.

Also drops the sliver filter Fields2Cover no longer needs: CorridorHL already removes the zero-width pieces carving leaves, and the degenerate-polygon crash the filter guarded against is fixed upstream.

(cherry picked from commit 8ecb2f4, part of #162)
(cherry picked from commit a4f3a87, part of #162)
Signed-off-by: u33549 <[email protected]>

* Remove the unused default_max_swaths_for_global_route parameter

It has had no effect since multi-cell TSP routing moved to a per-cell
solve; the threshold it set is no longer read.

(cherry picked from commit 852e0f1, part of #162)
Signed-off-by: u33549 <[email protected]>

* Report where a swath ends in the coverage path message

With Fields2Cover v2 a straight swath is a single path state, so taking
the end from that state's start point gave every swath start == end.
Use PathState::atEnd() instead.

(cherry picked from commit af70ccf, part of #162)
Signed-off-by: u33549 <[email protected]>

* Densify GPS paths before leaving the field frame

The densification step is in meters, but it ran after the path was
converted to the GPS frame, so swath lengths were in degrees and no
state was ever split.

(cherry picked from commit e7eb93b, part of #162)
Signed-off-by: u33549 <[email protected]>

* Fix the rolling CI build against nav2 main (#163)

* Use the ROS ompl that nav2 main builds against in CI

The CI dropped ros-rolling-ompl for the system libompl-dev 1.6 because
nav2 main was once written against the older ReedsShepp API. nav2 now
builds with the ROS ompl 2.x (and links its ompl::ompl target), so keep
it and drop libompl-dev.


* Include the ament_index_cpp header the navigator uses

coverage_navigator.cpp and its test call get_package_share_directory
but relied on nav2 headers to pull it in, which nav2 main no longer
does. Include it and declare the dependency.


* Build the navigator test's tf objects with the nav2 factories

Newer tf2_ros dropped the CreateTimerROS and TransformListener
constructors the test used. nav2::create_transform_buffer and
create_transform_listener pick the right ones for the installed rclcpp.


---------

Adapted for lyrical: the navigator's ament_index_cpp include and dependency are already on lyrical, so only the CI ompl change and the navigator test's tf2 factories apply. Lyrical's CI image, distro and launch_testing shim are kept.

(cherry picked from commit eb43d10)
Signed-off-by: u33549 <[email protected]>

* Build the lyrical CI against nav2's lyrical branch

nav2 main changed its TF API in ros-navigation/navigation2#6651
(FeedbackUtils::tf became tf_manager and tf2_factories.hpp is gone), so
the navigator no longer builds against it. Lyrical follows nav2's lyrical
branch, which keeps the API this package uses.

Signed-off-by: u33549 <[email protected]>

* Set headers on generated coverage path poses (#159)

* Set headers on generated coverage path poses


* Set pose headers in the PathState converter


---------

Adapted for lyrical: keeps lyrical's existing SWATH densify check in TesttoNavPathMsg.

(cherry picked from commit c4c1225)
Signed-off-by: Bram Odrosslij <[email protected]>
Signed-off-by: u33549 <[email protected]>

---------

Signed-off-by: u33549 <[email protected]>
Signed-off-by: Bram Odrosslij <[email protected]>
Co-authored-by: Bram O <[email protected]>
SteveMacenski pushed a commit that referenced this pull request Nov 27, 2026
* Pin Fields2Cover to v2.1.1 for the upstreamed fixes

Fields2Cover v2.1.1 carries the fixes and APIs this package used to work
around: HL_SWATH densification, the corridor headland and the
degenerate-polygon guard.

Adapted for humble: humble-v2 only pins Fields2Cover in deps.repos, so only its version changes; the README note is updated to match.

(cherry picked from commit 2ef1796, part of #162)
Signed-off-by: u33549 <[email protected]>

* Drop the unused multi-cell headland overload

The server only calls the Field overload; the F2CCells one had no
callers left after the headland-first decomposition rework.

(cherry picked from commit 93915e2, part of #162)
Signed-off-by: u33549 <[email protected]>

* Carve the inter-cell corridor with Fields2Cover

CorridorHL finds the borders cells really share and carves the corridor
from the smaller cell. route_headland_width is now the total corridor
width; the previous code could carve it from both cells, or miss a
partially shared border.

(cherry picked from commit 8ecb2f4, part of #162)

Also drops the sliver filter Fields2Cover no longer needs:
CorridorHL already removes the zero-width pieces carving leaves, and the
degenerate-polygon crash the filter guarded against is fixed upstream.

(cherry picked from commit a4f3a87, part of #162)
Signed-off-by: u33549 <[email protected]>

* Remove the unused default_max_swaths_for_global_route parameter

It has had no effect since multi-cell TSP routing moved to a per-cell
solve; the threshold it set is no longer read.

(cherry picked from commit 852e0f1, part of #162)
Signed-off-by: u33549 <[email protected]>

* Report where a swath ends in the coverage path message

With Fields2Cover v2 a straight swath is a single path state, so taking
the end from that state's start point gave every swath start == end.
Use PathState::atEnd() instead.

Adapted for humble: only the swath end test is added; the HL_SWATH and headland perimeter tests next to it on main belong to #141, which is not on humble.

(cherry picked from commit af70ccf, part of #162)
Signed-off-by: u33549 <[email protected]>

* Densify GPS paths before leaving the field frame

The densification step is in meters, but it ran after the path was
converted to the GPS frame, so swath lengths were in degrees and no
state was ever split.

Adapted for humble: the densify call takes main's zero-step guard (pt_dist <= 0 falls back to 0.1 m). On main it came with the headland driving change, which is not on humble.

(cherry picked from commit e7eb93b, part of #162)
Signed-off-by: u33549 <[email protected]>

---------

Signed-off-by: u33549 <[email protected]>
SteveMacenski pushed a commit that referenced this pull request Nov 30, 2026
* Pin Fields2Cover to v2.1.1 for the upstreamed fixes

Fields2Cover v2.1.1 carries the fixes and APIs this package used to work
around: HL_SWATH densification, the corridor headland and the
degenerate-polygon guard.

Adapted for jazzy: jazzy-v2 only pins Fields2Cover in deps.repos, so only its version changes; the README note is updated to match.

(cherry picked from commit 2ef1796, part of #162)
Signed-off-by: u33549 <[email protected]>

* Drop the unused multi-cell headland overload

The server only calls the Field overload; the F2CCells one had no
callers left after the headland-first decomposition rework.

(cherry picked from commit 93915e2, part of #162)
Signed-off-by: u33549 <[email protected]>

* Carve the inter-cell corridor with Fields2Cover

CorridorHL finds the borders cells really share and carves the corridor
from the smaller cell. route_headland_width is now the total corridor
width; the previous code could carve it from both cells, or miss a
partially shared border.

(cherry picked from commit 8ecb2f4, part of #162)

Also drops the sliver filter Fields2Cover no longer needs:
CorridorHL already removes the zero-width pieces carving leaves, and the
degenerate-polygon crash the filter guarded against is fixed upstream.

(cherry picked from commit a4f3a87, part of #162)
Signed-off-by: u33549 <[email protected]>

* Remove the unused default_max_swaths_for_global_route parameter

It has had no effect since multi-cell TSP routing moved to a per-cell
solve; the threshold it set is no longer read.

(cherry picked from commit 852e0f1, part of #162)
Signed-off-by: u33549 <[email protected]>

* Report where a swath ends in the coverage path message

With Fields2Cover v2 a straight swath is a single path state, so taking
the end from that state's start point gave every swath start == end.
Use PathState::atEnd() instead.

Adapted for jazzy: only the swath end test is added; the HL_SWATH and headland perimeter tests next to it on main belong to #141, which is not on jazzy.

(cherry picked from commit af70ccf, part of #162)
Signed-off-by: u33549 <[email protected]>

* Densify GPS paths before leaving the field frame

The densification step is in meters, but it ran after the path was
converted to the GPS frame, so swath lengths were in degrees and no
state was ever split.

Adapted for jazzy: the densify call takes main's zero-step guard (pt_dist <= 0 falls back to 0.1 m). On main it came with the headland driving change, which is not on jazzy.

(cherry picked from commit e7eb93b, part of #162)
Signed-off-by: u33549 <[email protected]>

* Let Fields2Cover plan the swath connections

Fields2Cover 2.1.1 follows a connection track and rounds its corners
(Fields2Cover#234). The local appendConnection drove a detour verbatim,
turning 90 degrees at every corner. Use F2C's route planPath instead.

Adapted for jazzy: the connection handling removed here is #137's, with its 1.3 length-ratio rule; the deviation rule and distanceToSegment from #145 are not on jazzy.

(cherry picked from commit 5b95534, part of #171)
Signed-off-by: u33549 <[email protected]>

* Reverse cell routes with Fields2Cover's Route::reverse

Adapted for jazzy: the anonymous namespace held only these two helpers here, so it goes too.

(cherry picked from commit 2909e11, part of #171)
Signed-off-by: u33549 <[email protected]>

* Drop guards Fields2Cover 2.1.1 no longer needs

shortestPath returns an empty path for a non-node endpoint instead of
throwing, and createShortestGraph leaves out swath ends outside every
cell (Fields2Cover#239). Use F2CPoint::getAngleDiffAbs for the heading
cost.

Adapted for jazzy: the bridge guard here was the earlier pair_cells.size() > 0 check (the two-cell check came with #145). The per-pair try/catch in routeThroughCell is #145 code and is not on jazzy.

(cherry picked from commit 4fd8f6b, part of #171)
Signed-off-by: u33549 <[email protected]>

---------

Signed-off-by: u33549 <[email protected]>
@u33549
u33549 deleted the use-fields2cover-2.1.1 branch November 30, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants