Repository navigation
Description
Summary
PathPlanning::simplifyConnection decides whether to follow a connection's waypoints or cut straight across them using the straight-line distance between the connection's endpoints, without ever measuring how far the waypoints in between actually depart from that line. When a connection detours around real geometry but happens to start and end close together, the waypoints are discarded and the path is planned straight through the obstacle the connection existed to avoid.
Reported against v2.0.0, the released version we depend on. I checked main and the v3.0 branch as well — the condition is byte-identical in all three, so this is not something an upgrade resolves.
Where
src/fields2cover/path_planning/path_planning.cpp:
std::vector<std::pair<F2CPoint, double>> PathPlanning::simplifyConnection(
const F2CRobot& robot,
const F2CPoint& p1, double ang1,
const F2CMultiPoint& mp,
const F2CPoint& p2, double ang2) {
const double safe_dist = getSmoothTurningRadius(robot);
std::vector<std::pair<F2CPoint, double>> path;
path.emplace_back(p1, ang1);
if (p1.distance(p2) < 6.0 * safe_dist || mp.size() < 2) {
path.emplace_back(p2, ang2); // <-- mp is discarded entirely
return path;
}
...p1.distance(p2) is the distance from the end of one swath to the start of the next. mp is the connection the route planner produced to get between them. The test relates the two endpoints to each other, but nothing in it looks at mp.
Why this is a problem
The two quantities are independent. A connection routed around a concave notch, or between two cells of a decomposed field, regularly has endpoints a few meters apart while the waypoints between them run for tens of meters around the boundary. Whenever that separation falls under 6 * safe_dist, mp is dropped and createTurn is asked for a direct maneuver between the two poses — straight across the ground the route deliberately went around.
A test on the deviation of mp from the segment p1–p2 would separate the two cases. The endpoint distance cannot, because a long detour and a short hop are indistinguishable by that measure.
Second issue in the same function
The corner test does not account for angle wrapping:
double ang_in = (mp[i] - mp[i-1]).getAngleFromPoint();
double ang_out = (mp[i+1] - mp[i]).getAngleFromPoint();
if (fabs(ang_in - ang_out) > 0.1) {
vp.emplace_back(mp[i]);
}getAngleFromPoint() returns mod_2pi(...), so it lands in [0, 2π). On a straight run heading near 0, consecutive segments can read as 0.001 and 6.282, giving fabs(...) = 6.281 and registering a corner where the polyline is straight.
Geometry::getAngleDiffAbs(a, b) already exists in the library and computes exactly this difference correctly. This one also reads the same on v2.0.0, main, and v3.0.
Versions checked
| endpoint-distance test | angle comparison | |
|---|---|---|
v2.0.0 (released) |
present | present |
main @ 0ce7fcc |
present | present |
v3.0 @ 884d895 |
present | present |
Context
Found while using F2C from opennav_coverage, where coverage of concave and decomposed fields produces exactly this connection shape. We are pinned to v2.0.0.
We already handle this downstream, in open-navigation/opennav_coverage#149: we follow the connection's polyline and decide the straight-hop case on how far mp deviates from the segment p1–p2, rather than on the distance between the endpoints. It's been exercised on concave and decomposed fields across a range of implement widths and turning radii.
If you'd like to look over what we did there and it seems like the right shape for F2C, I'd be glad to port it up against the v2 line.
Activity
SteveMacenski commentedon Aug 6, 2026
BTW @Gonzalo-Mier this came out of forward porting the Nav2 integration to V2
Gonzalo-Mier commentedon Aug 10, 2026
Hi @SteveMacenski, I'm in contact with @u33549 to achieve the integration of F2C v2 into Nav2
u33549 commentedon Aug 11, 2026
@Gonzalo-Mier i have a series of fixes to bring up from
opennav_coverage, where we have been working around F2C gaps downstream. This issue is the first; there are around ten, most small and self-contained. Several add API that is simply missing rather than only fixing behaviour — additive, nothing removed — so the shape is a minor release, not a patch.Could you open a
v2.1.0-develbranch offv2.1.0?u33549 commentedon Aug 11, 2026
For visibility, the full list. Each links to where we did it downstream.
Path planning
getSmoothTurningRadiusis private, so we re-derived it. #149TurningBasedoes not expose whether a curve is continuous-curvature. #149Types
Routehas noreverse(), thoughSwathandSwathsdo. #137HL_SWATHhas no producer and no consumer;discretizeSwathskips it. #113, #141Route planning
SingleCellSwathsOrderBasereturns ordered swaths but no connections. #145genSortedSwathssorts by swath id, so flattened multi-cell input interleaves the cells. #145createShortestGraphreturns a plausible but invalid path when only one cell is in the graph. #137shortestPaththrows when an endpoint is not a node. #145genRoutebuilds an all-pairs matrix and runs out of memory on multi-cell fields. #117CustomOrderfails late and unhelpfully on decomposed fields. #145setStartAndEndPointhas no meaning in a per-cell solve. #120, #137Headland / decomposition
ConstHL::generateHeadlandstreatsF2CCellsas one piece, so decomposed cells get no corridor between them. #135Coordinates
Not all of these are equally shaped for upstream — a few are workarounds where the
right fix is elsewhere in F2C, and I would rather fix the cause than port the
workaround.
u33549 commentedon Nov 21, 2026
Hi @Gonzalo-Mier, with #255 and #259 merged, the list above is done. Where each item ended up:
Merged
HL_SWATHproduced and consumed: Follow connection polylines instead of cutting across them #234getSmoothTurningRadiuspublic,TurningBase::hasContinuousCurvature,Route::reverse: Small API additions: Route::reverse, TurningBase::hasContinuousCurvature, public getSmoothTurningRadius #233createShortestGraphandshortestPathon single cells and off-node endpoints: Harden the shortest-path graph: node accounting, node lookup, and border edges #239CustomOrderchecked early: Order swaths per cell, and let the orderers produce a connected route #251Not needed in the library
genRouterunning out of memory was already fixed by Improvement: reduce memory usage #219; splitting per cell did not give better routes.Along the way: #247, #249, #250, #252, #253.
Everything from #250 on is only in
developso far. The Nav2 side (opennav_coverage) pins a release tag, so it can only drop its workarounds for #251, #254, #255 and #259 once they ship.Could you cut a new version from
developwhen you have a moment?Edit: I've changed my mind. For now, V2.1.1 is a good start, but it could be much better once the route-fix changes are merged into the next version.