Add TSP route ordering (Fields2Cover genRoute / OR-Tools) (Lyrical)#130
Merged
SteveMacenski merged 7 commits intoJul 16, 2026
Conversation
Adds a TSP route orderer (Fields2Cover genRoute / OR-Tools) as a new TSP route mode alongside BOUSTROPHEDON / SNAKE / SPIRAL / CUSTOM. Introduces a RouteMethod polymorphic layer unifying F2C's swath orderers (SingleCellSwathsOrderBase) and the OR-Tools route planner (RoutePlannerBase) behind one F2CRoute-returning call, so callers no longer branch on the route mode. RouteGenerator resolves the mode to a RouteMethod and exposes the TSP knobs (tsp_redirect_swaths, tsp_time_limit, tsp_search_for_optimum, tsp_d_tol) as parameters and the RouteMode message.
A single multi-cell genRoute call makes RoutePlannerBase build the full all-pairs path matrix, which exhausts memory (bad_alloc) on decomposed input. The cells are disconnected anyway, so TspRouteMethod solves each cell alone and stitches the per-cell routes in sweep order with straight-line bridges.
SwathGenerator::generateSwathsByCells returns per-cell swaths (F2CSwathsByCells) without flattening, so the route planner can follow each cell's borders. PathGenerator::generatePath now takes the ordered F2CRoute (headland connections included) instead of raw swaths, and a toCoveragePathMsg overload converts an ordered route's swath groups for the no-turns result.
coverage_server and row_coverage_server generate per-cell swaths, plan the ordered route (TSP or orderer) over them via RouteGenerator, and plan the connecting path over the resulting F2CRoute. An empty route is rejected, and the new TSP knobs are handled in the dynamic parameter callback.
Exposes the TSP route knobs (tsp_redirect_swaths, tsp_time_limit, tsp_search_for_optimum) as input ports on the ComputeCompleteCoveragePath behavior tree node, forwarding them into the RouteMode goal.
Covers TSP route generation, route-type resolution, and the TSP knobs across test_route / test_path / test_swath / test_server and the coverage BT tests. Bumps the test_server gtest timeout to 300s for the OR-Tools solve and raises the cancel BT service wait to 3000ms.
SteveMacenski
approved these changes
Jul 15, 2026
The navigator used ament_index_cpp::get_package_share_directory without declaring the dependency or including its header, relying on transitive includes. ament_index_cpp 1.14 (rolling/lyrical) removed that header, breaking the build with "get_package_share_directory is not a member of ament_index_cpp". Add the explicit dependency in package.xml and CMakeLists, and include the header in both the source and the test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lyrical port of #117. Adds a TSP-based route orderer — ordering the unordered
swaths via Fields2Cover's
genRoute(OR-Tools) — as a newTSProute mode,alongside the existing
BOUSTROPHEDON/SNAKE/SPIRAL/CUSTOMorderers.Targets
lyricaland builds on the earlier lyrical F2C v2 ports (most recentlythe decomposition port #126).
Changes
TSP route planning (core)
RouteMethodlayer unifying F2C's two unrelated route planners(
SingleCellSwathsOrderBaseorderers and the OR-ToolsRoutePlannerBase)behind one polymorphic call returning
F2CRoute, so callers no longer branchon the route mode.
RouteType::TSPand the TSP knobs, wrapping F2C'sgenRoutewith its OR-Toolsparameters.
coverage_server/row_coverage_server: whenroute_mode = TSP,swaths are ordered by the TSP planner and the connecting path is planned over
that route.
genRoutecallbuilds an all-pairs path matrix that exhausts memory, so the route is planned
per cell and stitched.
Interface changes (additive)
types.hpp:RouteTypeenum+ TSP.RouteMode.msg:modenow also acceptsTSP; new TSP knobstsp_redirect_swaths(bool),tsp_time_limit(s),tsp_search_for_optimum(bool).Note
This PR adds standalone TSP ordering for a single (non-decomposed) field or cell.
A follow-up PR will route decomposed (multi-cell) fields with the TSP planner,
connecting cells through their shared headland rather than a direct shortcut.