Repository navigation
Drive the cells in the order they are worth reaching - #255
Merged
Gonzalo-Mier merged 1 commit intoNov 17, 2026
Merged
Gonzalo-Mier merged 1 commit into
Gonzalo-Mier merged 1 commit into
Conversation
genRoute walked the cells in the order the decomposition produced them and always entered each one from the same end. That order is an artefact of how the field was cut up, so the route crossed the field to reach a cell it could have taken on the way, and entered cells against the direction it arrived from. The next cell is now the one that costs least to reach: distance measured through the headland graph, so a cell behind a wall is not mistaken for a near one, plus the turn needed to leave one cell and line up on the next. A cell whose far end is the nearer one is driven in reverse. A single cell has no order to choose and is untouched. setStartAndEndPoint says where the machine stands, which the orderers had no way to express: the route then starts at the cell nearest that point and returns to it, as RoutePlannerBase already did.
Contributor
Author
|
The one red job — and the same for matplot's It became visible in f154d70. Until then the workflow passed |
Contributor
Author
|
Hi @Gonzalo-Mier, can you check this pr pls. |
Member
|
Thank you really much @u33549!! |
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.
SingleCellSwathsOrderBase::genRoute— the route BOUSTROPHEDON, SNAKE, SPIRAL and CUSTOM produce since #251 — drives the cells in the order the decomposition happens to list them, and enters each one from the same end. That order says nothing about the field: the route crosses it to reach a cell it could have taken on the way, and enters cells against the direction it arrived from.What changes
The next cell is the cheapest one to reach from where the last one was left: the distance through the headland graph — so a cell on the other side of a wall is not taken for a near one — plus the turn needed to line up on it. Where the graph cannot connect two cells, as between two separate fields, it falls back to the straight-line distance.
A cell is driven in reverse when its far end is the nearer one.
The start is given, not searched for. The route starts at the first cell handed over or, new here, at the cell nearest the point passed to
setStartAndEndPoint, and returns to that point — the contractRoutePlannerBasealready offers. From there each step takes the cheapest next cell; it does not try every order.A single cell has no order to choose and is untouched.
Two scenes from the tests
Real library output on this branch: same field, same cells, same swaths on both sides, only the route differs. Only the drives between cells are drawn, since the turns inside a cell are the same on both sides. Cell 1 is the given start in both.
The cells are handed over left, right, middle. Today the route passes the middle cell to reach the far one, then drives back for it.
Two rooms joined only at the far end. From the start, the cell behind the wall is 20 m away in a straight line and 210 m to drive. Measuring through the headland graph is what keeps the route from going there first.
Where the cells already arrive in a good order — the same rooms handed over from the far left — today and this PR drive the same route.
On real fields
350 fields with OSM boundaries,
ConstHL,BoustrophedonDecomp(π/2), a 4 m implement, the route driven throughplanPathwith Dubins turns. 126 fields come out as a single cell and are untouched. On the other 224 — 5 cells at the median — today's library against this branch:Why the graph distance. A probe that implements the same rule both ways, on the same 224 fields: with the graph distance it saves 15.3 % of empty travel at the median and does worse than today on 4 fields; with a straight line it saves 12.0 % and does worse on 20. That is the wall scene at field scale.
Tests
multicell_route_test.cpp:visitsCellsInAReasonableOrder,doesNotMistakeACellBehindAWallForANearOne— the two scenes aboveentersACellFromTheNearerEnd,drivesEachCellInOneBlockstartsAtTheCellNearestTheStartPoint,connectsBothEndsToTheStartPoint,withoutAStartPointTheRouteIsUnchangedfallsBackToStraightLineWhereTheGraphCannotReach,emptyCellsAreSkipped,singleCellIsUntouchedeveryPatternOrdersItsCells— the order lives in the base class, so every pattern gets itmulticell_route_test.pyreachessetStartAndEndPointfrom Python.