Skip to content

Proper full workflow example for complex field geometries #208

Closed

Description

@yuri-rage

All examples regarding use of the path planner cull a single cell from the field geometry like this:

F2CSwaths swaths = bf.generateSwaths(M_PI, robot.getCovWidth(), no_hl.getGeometry(0));

The advanced route planners (Boustrophedon, snake, spiral) and path planner only deal in single cell swaths (not SwathsByCell) generated by the above example, whereas the base route planner will use the entire field geometry. Therefore, it seems impossible to use the advanced sorting features on fields with complex geometries (holes).

Am I missing part of the workflow, or is this a missing feature?

Activity

  1. Gonzalo-Mier commented on Jun 12, 2025

    @Gonzalo-Mier
    Member

    Hi @yuri-rage, welcome to the project. Thank you for pointing this out, because it's true that it's not in the documentation and should be fixed.
    First, Boustrophedon, snake, spiral are not advanced route planners. They are patterns and they only work in convex cells. That's why we can only use them on F2CSwaths and not F2CSwathsByCell. To use an advanced route planner, we need a metaheuristic. Something like:

    f2c::hg::ConstHL const_hl;
    F2CCells mid_hl = const_hl.generateHeadlands(cells, 1.5 * robot.getWidth());
    F2CCells no_hl = const_hl.generateHeadlands(cells, 3.0 * robot.getWidth());
    
    f2c::sg::BruteForce bf;
    F2CSwathsByCells swaths = bf.generateSwaths(M_PI/2.0, robot.getCovWidth(), no_hl);
    
    f2c::rp::RoutePlannerBase route_planner;
    F2CRoute route = route_planner.genRoute(mid_hl, swaths);
    

    Note that we have a F2CRoute at the end. On it, we saved the swaths (information from F2CSwathsByCell) and their connections.

    Once we have the F2CRoute, we plan the path as we would do it with the F2CSwaths:

    F2CRobot robot (2.0, 6.0);
    robot.setMinTurningRadius(2);  // m
    robot.setMaxDiffCurv(0.1);  // 1/m^2
    f2c::pp::PathPlanning path_planner;
    f2c::pp::DubinsCurves dubins;
    F2CPath path_dubins = path_planner.planPath(robot, route, dubins);
    

    And that's all. If you have any more doubts, please ask 😄

  2. yuri-rage commented on Jun 13, 2025

    @yuri-rage
    Author

    Thank you for the quick feedback. You've done a good job differentiating the planning stages with use of specific terminology, which I admit I confused slightly. Just to confirm:

    There is no existing workflow that would allow for the use of pattern sorting (Boustrophedon/snake/spiral) on geometries containing more than one cell (specifically, a cell with "holes" created by fully contained inner geometries).

    Do I have that correct?

  3. Gonzalo-Mier commented on Jun 13, 2025

    @Gonzalo-Mier
    Member

    That's correct.

    Let me explain the problem. Imagine that we have a square field with a square inner obstacle in the middle. We decide to split the field into 4 cells: left, top, bottom, and right. We want to do boustrophedon, and we start at the first swath of the field, in the left side, covering to the right. The problem is that once we found the obstacle, we have to decide to cover the top or the bottom cell. Imagine that we go for the top cell, and then we follow the right direction to the right cell... The bottom cell is uncovered, and we have to go back breaking the pattern. With the snake pattern is even more difficult.

  4. lyfkyle commented on Jun 13, 2025

    @lyfkyle
    Contributor

    Just to chip in, you need to plan the path to move between cells by yourself. In my project, I get the ordered swaths from F2C without using the path planner. And use Nav2 separately to connect them.

    F2C's path planner assume there exists simple paths that connect swaths and they all naturally lie in the headland so there is no collision. This assumption breaks if you have cell with holes

  5. Gonzalo-Mier commented on Jun 13, 2025

    @Gonzalo-Mier
    Member

    In my project, I get the ordered swaths from F2C without using the path planner. And use Nav2 separately to connect them.

    Hi @lyfkyle, would be awesome to have something similar directly on Fields2Cover. Do you think it could be implemented without Nav2?

    F2C's path planner assume there exists simple paths that connect swaths and they all naturally lie in the headland so there is no collision. This assumption breaks if you have cell with holes.

    Not really. The route planner is able to create a route that do not cross through the field borders or the holes. The problem is a simplification step in the path planner, to smooth the path. That's why you may see some crossing.

  6. lyfkyle commented on Jun 13, 2025

    @lyfkyle
    Contributor

    Hi @lyfkyle, would be awesome to have something similar directly on Fields2Cover. Do you think it could be implemented without Nav2?

    For sure, A simple A* should suffice. But sadly I do not have bandwidth to contribute in the short term.

    Not really. The route planner is able to create a route that do not cross through the field borders or the holes. The problem is a simplification step in the path planner, to smooth the path. That's why you may see some crossing.

    Oh, that's interesting. I am not aware of the path simplification step. In my previous test the path passes through the center cell (which is an obstacle in my case) that's why I switch to use Nav2.

  7. Gonzalo-Mier commented on Jun 13, 2025

    @Gonzalo-Mier
    Member

    For sure, A simple A* should suffice.

    Do you have any way to check that the curvature and the steering rate are not too high?

  8. yuri-rage commented on Jun 13, 2025

    @yuri-rage
    Author

    For my case, I think I will plan separate field objects whose sides intersect the obstacle cells. This results in a very clean path generated by F2C, whether sorting is employed or the route planner is used. So I can still avoid obstacles, I just have multiple plans, and as @lyfkyle says, manually plan the transition between. I can live with this as a near-term (and possibly permanent) solution, but it would be nice to have a more robust workflow overall.

    For example, sectioning a field like this:
    Image

  9. yerongguang commented on Jun 18, 2025

    @yerongguang

    I also encountered the problem of routes crossing the map. It should be caused by the direct connection between two points between different partitions, but it is obviously unreasonable. How can we not realize the navigation connection between partitions based on Costmap?

  10. Gonzalo-Mier commented on Jun 18, 2025

    @Gonzalo-Mier
    Member

    Hi @yerongguang, I don't understand your message well. Can you provide an example?

  11. ironoa commented on Jun 21, 2025

    @ironoa

    Hi @Gonzalo-Mier, forgive me if this is not the right place to write it, but I think I may have a related issue:

    Image

    what you are seeing here above are routes and swaths only. As you can see, there is a diagonal route that is crossing through 2 obstacles, that's my problem.

    I am using SG_BruteForce for swaths generation, RP_Boustrophedon to sort the swaths, and RP_RoutePlannerBase to plan the route


    Following the full area which shows swaths and path. As you can see, again, multiple glue routes are crossing the obstacles. Same setup, with PP_ReedsSheppCurvesHC for path generation

    Image

    Anyway, the problem it's at the route level. Any suggestion ?

  12. Gonzalo-Mier commented on Aug 4, 2025

    @Gonzalo-Mier
    Member

    Hi @ironoa, sorry for the delay. The route planner cannot find a proper solution in your cases. There is a bug here and we have to fix it. Thank you for reporting

  13. added
    bug
    and removed
    bug
    on Aug 4, 2025
  14. Gonzalo-Mier commented on Aug 4, 2025

    @Gonzalo-Mier
    Member

    I proceed to close this issue due to the original question is answered already. If it is not, feel free to open it again. The new bug about the route planner is moved to a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions