You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Idea - add minimum distance cost/penalty for ortools::RoutingModel for emergent snake/spiral behaviour. #149
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.
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?
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?
@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.
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 :)
Activity
Gonzalo-Mier commentedon May 27, 2024
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?
vtasStu commentedon Dec 25, 2024
Could you give some guide on how to open the cost function to generate a snake path?
Gonzalo-Mier commentedon Dec 27, 2024
Continue to #76 (comment)
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.
vtasStu commentedon Dec 27, 2024
@Gonzalo-Mier
Thank you very much for your prompt response.
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.but the resulting path still follows a boustrophedon order rather than a SNAKE order.
Due to my limited understanding, I am not sure what you mean by adding the loss after obtaining the route.
Gonzalo-Mier commentedon Dec 27, 2024
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 by1.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 the1.5by1e5and hopefully it will understand your intentions :)