Fields2Cover / Fields2Cover

Robust and efficient coverage paths for autonomous agricultural vehicles. A modular and extensible Coverage Path Planning library
https://fields2cover.github.io/
BSD 3-Clause "New" or "Revised" License
456 stars 96 forks source link

Using Swaths vs Route for path planning. #116

Closed ar0ser0 closed 2 months ago

ar0ser0 commented 3 months ago

Hi @Gonzalo-Mier,

As far as documentation goes, it would be nice to have more descriptions about the differences between the RoutePlannerBase class and the SingleCellSwathsOrderBase subclasses. The reason being is that the output types of both classes can be used in the path planning step, but one outputs a Route type which contains information about swath connections, while the other outputs a Swaths type which has no information about the swath connections. It was confusing to me until I realized they were different types. Both have advantages and disadvantages in different cases so a clear explanation of the differences would help to discern which is right for the user more quickly.

For example, for complex (concave and convex) cell shapes SingleCellSwathsOrderBase works better using decompose, but because of the lack of swath connection information (they are swaths not a route), path planning connects the cells directly in a straight line rather than through the headlands. If you want to connect swaths through the headlands by making a route with RoutePlannerBase, then you can't use the patterns from SingleCellSwathsOrderBase.

Another thing to note when making a route with the RoutePlannerBase is that it rewrites swath ordering and direction. So it doesn't make sense to make a custom swath order and then use it solely for the additional swath connection information to be able to travel through the headlands.

This is my current understanding so please correct me if I am wrong. Thanks!

ar0ser0 commented 3 months ago

And to be clear, when I mention RoutePlannerBase, SingleCellSwathsOrderBase, and "path planning" im also referring to genRoute() and genSortedSwaths(), and planPath() respectively.

Gonzalo-Mier commented 3 months ago

Hi @ar0ser0,

I completely understand the misunderstanding. I'll try to explain it a bit here:

As far as documentation goes, it would be nice to have more descriptions about the differences between the RoutePlannerBase class and the SingleCellSwathsOrderBase subclasses. The reason being is that the output types of both classes can be used in the path planning step, but one outputs a Route type which contains information about swath connections, while the other outputs a Swaths type which has no information about the swath connections. It was confusing to me until I realized they were different types. Both have advantages and disadvantages in different cases so a clear explanation of the differences would help to discern which is right for the user more quickly.

A Route is composed by Swaths and MultiPoints (connections).

RoutePlannerBase is a optimizer that sort near-optimally the swaths (and how to go from one to other). Then, RoutePlannerBase does the same with a Swaths, or with a Route with no connections and only one Swaths.

On the other hand, SingleCellSwathsOrderBase doesn't optimize or give information about connections. It just sorts swaths with a givven pattern. Due to that, it only returns Swaths and no Route.

For example, for complex (concave and convex) cell shapes SingleCellSwathsOrderBase works better using decompose, but because of the lack of swath connection information (they are swaths not a route), path planning connects the cells directly in a straight line rather than through the headlands. If you want to connect swaths through the headlands by making a route with RoutePlannerBase, then you can't use the patterns from SingleCellSwathsOrderBase.

If your field is convex and you want to apply a known pattern, use SingleCellSwathsOrderBase. Otherwise, RoutePlannerBase will find better routes.

Another thing to note when making a route with the RoutePlannerBase is that it rewrites swath ordering and direction. So it doesn't make sense to make a custom swath order and then use it solely for the additional swath connection information to be able to travel through the headlands.

You are right! Use one or the other.

Feel free to improve the docs with a PR if you want :)