Repository navigation
Conversation
Following a connection's track needs a handful of plain geometry: the turn between two headings, the distance from a point to a segment, a point a given way along one, Douglas-Peucker thinning, and how far a planned path strays from the polyline it stands in for. None of it knows anything about coverage, so it sits in utils rather than in the path generator that uses it. Also a spreadsheet-style label for a connection turn, so the same turn can be named in the debug log and in RViz.
A connection was driven as a straight turn from the end of one swath group to the start of the next. That holds for the u-turn between neighbours, where the track is the hop itself, but not for a detour around a concave notch or between decomposed cells, where it cut across ground the route had deliberately routed around. Follow the connection's own track instead, rounding its corners through the turn planner and leaving them square where no maneuver fits within half an operation width of the track. Which of the two a connection gets is decided by how far the track strays from the straight hop, not by their length ratio: rounding a long cell's corner is only about 20% longer than cutting its diagonal yet shares no ground with it. The corners at either end are planned from the headings of the swaths there, not from the track's first and last legs. The border graph splices the swath endpoint into the ring, so those legs are often a short spur the robot is not driving along, and reading the heading off them plans the turn from a pose the robot is never in - a 90 degree corner comes out as an S, a reversal as an L, and the arc meets the swath at a cusp. Corners too close together to take one at a time are folded into a single maneuver for the same reason. Sharp corners are reported once per path as a warning; the per-corner detail is at debug level.
The turns planned between swath groups are hard to pick out of the coverage path, which is what makes a corner that came out wrong hard to see. Publish them on their own topic as a marker array, each labelled the way the debug log names it, so a turn on screen can be matched to the line that produced it. Cleared per request, so one field's turns are not drawn over the next.
A candidate maneuver is rejected when it strays further from the track than the corridor allows, except for a u-turn, which was exempt: a u-turn has to swing past its vertices to come round and would fail the check by construction. That left it unchecked rather than checked loosely. Whether a connection is a u-turn is a guess, made from the reversal angle and a hop that scales with the operation width, and it is the one classification reachable in error - when it is wrong, nothing bounds where the maneuver goes. The length budget does not cover it either: a curve can be the right length and still bulge the wrong way. Allow it the corridor plus the diameter it turns on, which is what a u-turn legitimately needs, and hold it to that. The allowance is in turning radii, so it does not inflate with the implement.
How far rounding a connection's corner may leave the track it follows was a compile-time fraction of the operation width. It is a tolerance the operator sets, not a property of the algorithm: how much ground a machine may cut across depends on the field and on what the implement is doing, and the same figure decides whether a corner is rounded at all or left square. Declare it as `corner_cut_tolerance` in meters, defaulting to half the operation width so existing behaviour is unchanged, and reconfigurable at runtime on both servers. The sharp-corner warning now names it as the thing to raise.
Cover the junction with a swath, where the connection's own track says nothing about the heading the robot leaves on; two corners too close to round one at a time, which have to be folded into a single maneuver; the open ends of a route, which hold no heading and so are no corner; and the floor under a shallow corner's approach, without which the planner is handed two poses centimetres apart. The first two fail without the change they cover. The other two pin behaviour that was previously untested.
The corner code reads active_continuity_type_ to decide whether a turn needs the wider radius a continuous curvature curve does, but nothing ever set it. Left at UNKNOWN it read as discontinuous, so turnRadius() never grew the radius and linear_curv_change had no bearing on a connection's turns. Assign it where the mode is resolved. Fields using a high curvature rate are unaffected - the clothoid ramp never binds there - but at the default rate a 90 degree corner now plans on a 0.56m radius rather than the 0.4m floor.
|
I know it's a really long pr, but since it forms a meaningful whole, I couldn't split it up. |
SteveMacenski
left a comment
There was a problem hiding this comment.
I don't really understand this PR.
Why is this happening in the first place and isn't that a bug that should be resolved within F2C APIs instead of creating our own thing here? This is no longer simply a wrapper on F2C for ROS/Nav2 but definiting its own capabilities which is not the intent of the project. It seems to me that there's either a bug in F2C or we're not using it correctly causing an issue (or is this issue not really an issue at all but a misuse of APIs?)
| label.insert(label.begin(), static_cast<char>('A' + idx % 26)); | ||
| idx = idx / 26; |
There was a problem hiding this comment.
This is a bit unusual. Why not simply number them like everything else?
There was a problem hiding this comment.
In Rviz, the numbers sometimes appear side by side; to separate them, I used letters instead of numbers for debugging purposes, but I can remove this feature.
| inline double sweepBetween(double from, double to) | ||
| { | ||
| const double d = to - from; | ||
| return std::fabs(std::atan2(std::sin(d), std::cos(d))); |
There was a problem hiding this comment.
I think angles lib does this
There is a genuine F2C bug, and it's still open upstream
The reason we stopped calling it, back in open-navigation/opennav_coverage#137 ("Follow route connections in the path when they detour"), is this line in if (p1.distance(p2) < 6.0 * safe_dist || mp.size() < 2) {
path.emplace_back(p2, ang2); // the polyline is discarded here
return path;
}It decides whether to follow the connection's polyline or cut straight across it by the straight-line distance between its endpoints alone — never by how far the polyline in between actually strays from that line. A detour around a concave notch or between decomposed cells routinely has its endpoints within I checked this isn't fixed in the meantime: it's identical in the pinned v2.0.0 and in the current upstream tip (the in-progress v3 rework touches everything around it but leaves this exact condition untouched). I'd also tried F2C directly before working around it, not just read the source — the results were poor on exactly the fields this matters for, concave and decomposed ones, which is what sent me looking for why. The heading bugs were ours, not F2C's — but going back isn't the fix eitherThe bugs this review caught — the S-shape, the teardrop, the wrong L — all trace back to one thing: our version read the heading at each end of a connection off the polyline's own first and last leg. That doesn't make So the corner logic here does more than Why this isn't an isolated callThe corridor routing from an earlier PR diverges from F2C's own approach for the same kind of reason, and the per-cell TSP routing before that replaced F2C's global Where these patches should liveIf it keeps this package from turning into a shadow of F2C, I'd rather fixes like this one not live inside |
|
What is the reason a PR can't be opened against F2C to resolve this issue and we target that newer verssion once merged? |
|
I open the upstream issue (and a PR if they want it), and this workaround stays here until that fix is released and we've migrated to the version that has it, then we drop this branch. |
|
Can you link the ticket/PR here so this is all cross referenced? I'd prefer to hold off until we hear back on that (or if we don't hear for a very long time) |
|
It's done. I'd appreciate it if you could take a look when you have a chance. |
|
Hi @SteveMacenski, |
|
Closing this in favour of #162. Following the connections between swath groups now lives in Fields2Cover (Fields2Cover#234, released in v2.1.0), and since #162 main uses F2C v2.1.1 instead of the downstream copy. The remaining smoothing work for connection paths will go into Fields2Cover first and come back here as a thin wrapper PR once it is released. Thanks for the reviews! |







Problem
A connection between two swath groups was always driven as a single turn from the end of one group to the start of the next, ignoring the connection's own waypoints.
That is right for the u-turn between neighbouring swaths, where the track is the straight hop. It is wrong everywhere else. On a detour around a concave notch, or between decomposed cells, the route deliberately walks the border to stay inside the field, and planning a turn straight across it cuts through exactly the ground the route was avoiding.
Approach
Follow the connection's own track, rounding its corners through the turn planner and leaving a corner square when no maneuver fits within half an operation width of it.
Which of the two treatments a connection gets is decided by how far its track strays from the straight hop, not by the ratio of their lengths. A long cell's rounded corner is only about 20% longer than the diagonal across it, yet shares no ground with it, so a length ratio cannot tell them apart.
The corners at either end are planned from the headings of the swaths there, not from the track's first and last legs. The border graph splices the swath endpoint into the ring, so those legs are often a short spur that the robot is not driving along. Reading the heading off them plans the turn from a pose the robot is never in: a 90° corner comes out as an S, a reversal as an L, and the arc meets the swath at a cusp. Corners too close together to be taken one at a time are folded into a single maneuver for the same reason.
Known limitations
Two things I deliberately left out of this PR rather than hide:
kCornerCutTolis a compile-time constant (0.5 × operation_width). It is really a user-facing tolerance — how far a rounded corner may leave the track — and belongs as a ROS parameter besideoperation_widthandmin_turning_radius. Kept as a constant here to hold the PR to one concern; happy to add the parameter here instead if you would rather it landed together.The turn maths is heuristic and carries a number of tuning constants — the block at the top of
path_generator.cpp. They are all fractions of the operation width or multiples of the turning radius, never absolute distances, but they are tuned rather than derived and are the part most worth a second opinion.