Repository navigation
Small API additions: Route::reverse, TurningBase::hasContinuousCurvature, public getSmoothTurningRadius - #233
Merged
Gonzalo-Mier merged 4 commits intoAug 18, 2026
Conversation
Contributor
Author
|
@Gonzalo-Mier Is there anything need to change here |
Member
|
Hi @u33549, Thank you for the PR! Seems great |
Gonzalo-Mier
pushed a commit
that referenced
this pull request
Aug 22, 2026
* Discretize HL_SWATH sections in Path::discretizeSwath discretizeSwath() only densified SWATH states; HL_SWATH stayed a single waypoint, so headland/corridor legs stored with that type couldn't be subdivided. Neither type has ever been produced by F2C itself (HL_SWATH has been dead since the v2.0.0 initial commit), so no existing call path changes behavior. * Add appendSwath overload to set PathSectionType The only public way to produce an HL_SWATH state was building a PathState by hand and calling addState. appendSwath always hardcoded SWATH. New overload takes the type explicitly; the 2-argument version now delegates to it with SWATH, so the existing signature and ABI are unchanged. * Follow and smooth connection polylines instead of a raw corner turn planPathForConnection routed every consecutive waypoint pair through the turn planner, including straight legs, and simplifyConnection's angle-wrap bug (fabs on a raw angle difference) mis-simplified sharply-turning tracks. Replace both with a corner-by-corner planner: straight runs become HL_SWATH legs, only genuine corners go through createTurn, and corners too tight or too close together are folded or left sharp rather than plotting a shortcut across ground the route routed around. Four details the geometry needs: - The approach to a corner is sized from the radius the turn actually sweeps, which is the wider of two effects: the clothoid ramps spend part of the deflection (getSmoothTurningRadius, public since #233), and a shallow corner never reaches full curvature at all, peaking at sqrt(rate * sweep). Take only the first and a shallow corner is planned from a radius it never drives, which starts the turn a metre early and cuts ground the legs either side of it are covering. - A candidate turn is judged by how far it turns, not how long it is. A loop costs an extra 2*pi*R, which at a small turning radius is a couple of metres and hides inside any length budget, but it cannot hide in the turning itself. - cut_tol is floored in turning radii and capped at the operation width, so a compact implement still gets room for a fillet while a wide-turning one keeps the corners it should leave square. - The tangent margin is room for a clothoid lead-in, so it applies only to a continuous-curvature turn; a discontinuous one needs the plain tangent length and cutting more would only cut corner. At a pinned route end taking a single corner there is no outgoing leg -- the reference point is the corner itself -- so the lateral-offset bound collapses to zero and would refuse a corner the tangent bound allows. Skip it there. Enables the fields2cover_pp_pp.planPathForConnection test, dead since v2.0.0's first commit. * Add connection corner regression tests Nine tests over the corner-rounding path, which had no coverage before: detour corners, tight jogs folded into one S, neighbour u-turns, curved tracks that must not be flattened, corners left sharp because no turn fits, corners taken from the swath's heading rather than the track's, open-ended route connections, shallow-corner approach floors, and corners too close to round one at a time. Each bound here was checked by reverting the code it covers and confirming the test goes red, so none of them is decorative. Two are worth naming: the shallow-corner test bounds the approach on both sides, because starting a turn too early cuts ground the covering legs either side of it need; and maxTurnSweep is what catches a turn planner answering with a loop, which is smooth, barely longer, and invisible to every other measure here. distanceToPath measures to the polyline through the states, not to the states themselves: a straight run is one state, so measuring to states alone would miss the track between them. * Add the geometry helpers the corner planner needs to their own types Following a connection's track needs a handful of plain geometry that has nothing to do with path planning: a point a given way along a ray, the points of a geometry as a vector, appending a straight leg to a path, and how far a path strays from a line. Point::getPointAlong, MultiPoint::toVectorPoint, LineString::toVectorPoint, Path::appendStraight and Path::maxDistanceTo. appendStraight takes a speed rather than a Robot, matching appendSwath -- Robot.h already includes Path.h, so the dependency cannot run the other way. * Move turn geometry and its tuning onto Robot getSmoothTurningRadius computes a property of the robot, and the corner planner needs two more of the same kind: the radius a turn of a given deflection is driven at, and the tolerances and thresholds that decide whether a corner is rounded at all. Robot::getSmoothTurningRadius and Robot::getTurnRadius, plus settable parameters for the corner planner. The four that scale with the machine are stored in real units and derived from the robot when unset -- an operator sets "at most 1.25 m of corner may be cut", not a fraction -- following the turn_vel_ precedent already in the class. * Use the type-level helpers in the connection planner The anonymous namespace was carrying general-purpose geometry and a block of tuning constants that callers had no way to reach. Both now live on the types they describe, so this file keeps only the cornering logic. getSmoothTurningRadius stays on PathPlanning as a forwarder: it was made public one release ago, and moving it outright would break callers. * Split appendRoundedTrack into its named steps At 185 lines the reasoning was hard to follow. Same logic, in the four steps it was already doing: the deflection at each corner, the fold of corners too close to take one at a time, the room a span leaves for a maneuver, and the search for a turn that fits it. No behaviour change. * Drop the addStraight wrapper, call Path::appendStraight directly The wrapper still took F2CPath& and mutated it, the exact pattern the review asked to move off of -- moving the logic onto Path only helped if callers actually called the member function. * Fix the reason a wide-radius corner stays sharp in the test comment * Move doc comments off the public getters onto their members
This was referenced Nov 21, 2026
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.
Motivation
Three pieces of information the library already has internally but does not offer to
callers: the radius a continuous-curvature turn sweeps, whether a turn planner keeps the
curvature continuous, and reversing a route.
Each one currently forces the caller into something worse — duplicating a formula it
cannot compute exactly, branching on concrete planner types, or rebuilding a
Routebyhand. All three are additive, none changes behavior, and each is one commit.
They are prerequisites for the
planPathForConnectionfix (#231), but they are gaps intheir own right, and sending them first keeps that fix reviewable as a single concern.
1. Make
PathPlanning::getSmoothTurningRadiuspublicMoved the declaration from the private block to the public one. Body untouched.
The value cannot be computed outside the library: the function calls
end_of_clothoidfrom
steering_functions/utilities/utilities.hpp, and those headers are not part of theinstall (only
fields2coverandmatplotland in the install prefix). We currentlyapproximate it downstream with a different formula, which drifts from what F2C itself
plans.
2. Add
TurningBase::hasContinuousCurvature()Added
virtual bool hasContinuousCurvature() constreturningfalse, overridden totrueinDubinsCurvesCCandReedsSheppCurvesHC.Choosing the radius to round a corner with depends on whether the turn planner ramps the
curvature or steps it. A caller holding a
TurningBase&has no way to ask, so it wouldhave to branch on the concrete type and silently pick wrong for any planner added later.
Querying the robot instead is not equivalent:
tutorials/6_path_planning.cppdrivesplain
DubinsCurveswith a robot that hasMaxDiffCurvset. Continuity is a property ofthe planner, not of the robot.
Left non-pure so that
TurningBasesubclasses outside this repo keep compiling.3. Add
Route::reverse()Reverses the group order, each
Swaths, eachSwath, and the point order of eachconnection.
Swath::reverse()andSwaths::reverse()already exist —Routewas the missing one,so anything that needs a route driven backwards has to rebuild it by hand.
One detail worth a look during review: connections are stored before the swaths they
lead into and the trailing one is optional, so
connections_.size()is eitherv_swaths_.size()or one more. Reversing both vectors on their own shifts theconnections by one whenever there is no trailing connection. The implementation appends
an empty connection first when needed and drops a trailing empty one afterwards, so
reversing twice returns the exact original, connection count included.
Two smaller things:
Swaths::reverse()only reverses the swath order and not the drivingdirection of each swath, so
Swath::reverse()is called per swath as well; andMultiPointhas noreversePoints()(unlikeLineString/LinearRing), so connectionsare rebuilt.
Note
Adding a virtual method changes the vtable layout, so this is an ABI break.