Skip to content

Idea - add minimum distance cost/penalty for ortools::RoutingModel for emergent snake/spiral behaviour. #149

Open

Description

@aosmw

I was curious as to how the snake and spiral case options might be added to the planCovRoute(). I understand that this function uses ortools::RoutingModel underneath which is how I think the v2 is able to deal with internal no-go/keep out zones.

I note the new redirect_swaths feature added in #129 that allows partial guidance from the original sorting methods.

I wonder if there is a way to get emergent snake and/or spiral behavior from the ortools::RoutingModel by adding penalties for joining swaths that are too close to each other.

Activity

  1. Gonzalo-Mier commented on May 27, 2024

    @Gonzalo-Mier
    Member

    Hi @aosmw. Spiral might be more difficult, but for snake I would add a penalty if distance between start and end nodes are closer than 1.9 cov width. Doing that, it will avoid moving to exactly the next one, and it will appear something similar to the snake pattern. Does it make sense?

  2. vtasStu commented on Dec 25, 2024

    @vtasStu

    Hi @aosmw. Spiral might be more difficult, but for snake I would add a penalty if distance between start and end nodes are closer than 1.9 cov width. Doing that, it will avoid moving to exactly the next one, and it will appear something similar to the snake pattern. Does it make sense?

    Could you give some guide on how to open the cost function to generate a snake path?

  3. Gonzalo-Mier commented on Dec 27, 2024

    @Gonzalo-Mier
    Member

    Continue to #76 (comment)

    However, the optimization results are not satisfactory.

    Not sure what you mean with that.

    The code you provide seems wrong. Do not touch the algorithm. Add the cost multiplication later, once you have the coverage graph.

  4. vtasStu commented on Dec 27, 2024

    @vtasStu

    @Gonzalo-Mier
    Thank you very much for your prompt response.

    The code you provide seems wrong.

    Based on the ideas you mentioned, I attempted to modify the loss function. My understanding is that the order of swaths is obtained from route_planner.genRoute. To achieve the SNAKE order, I increase the nearest dist in Floyd's algorithm rather than the distance in the or-tools optimizer. The code I posted earlier had some issues. I've corrected it below.

      // Initialize distances and paths for direct connections
      for (const auto& src : this->edges_) {
        for (const auto& dest : src.second) {
          dist[src.first][dest.first] = dest.second;
          next[src.first][dest.first] = dest.first;
          // 0.5 is operator width
          if (dest.second  < 1.9 * 0.5 * 1e3)
          {
            dist[src.first][dest.first] += 1.5 * dest.second;
          }
    
        }
        dist[src.first][src.first] = 0;
      }
    

    Not sure what you mean with that.

    but the resulting path still follows a boustrophedon order rather than a SNAKE order.

    Add the cost multiplication later, once you have the coverage graph.

    Due to my limited understanding, I am not sure what you mean by adding the loss after obtaining the route.

  5. Gonzalo-Mier commented on Dec 27, 2024

    @Gonzalo-Mier
    Member

    The Floyd–Warshall algorithm is used to find the shortest path in a graph between any pair of points. In the code you provide, you are modifying the way the algorithm works. We don't want that. We want to know the distance between any two points (wait until this alg is finished), and if the distance of a pair of points is smaller than 1.9 * 0.5 * 1e3, then and only then you can multiply that cost by 1.5 (or whatever you want). With those new costs you can run the optimization process. If after that it still follows the boustrophedon, then change the 1.5 by 1e5 and hopefully it will understand your intentions :)

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