Skip to content

Commit

Permalink
Merge pull request #573 from eyal0/backtrack_path_finding
Browse files Browse the repository at this point in the history
fix: Use backtracking limit in path_finding
  • Loading branch information
eyal0 committed Apr 9, 2021
2 parents 56a6103 + 1a7969b commit e7c1175
Show file tree
Hide file tree
Showing 17 changed files with 786 additions and 3 deletions.
1 change: 1 addition & 0 deletions integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"am-test-voronoi-front",
"am-test-voronoi-wide-extra-passes",
"backtrack",
"backtrack_0",
"D1MiniGSR",
"edge-cuts-broken-loop",
"edge-cuts-inside-cuts",
Expand Down
3 changes: 3 additions & 0 deletions path_finding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ optional<linestring_type_fp> PathFindingSurface::find_path(
// in_surface builds up some structures that are only efficient if
// we're doing many tries.
return {{start, goal}};
} else {
// If the straight line was too long then there is no way to connect.
return boost::none;
}
}
} catch (GiveUp g) {
Expand Down
17 changes: 14 additions & 3 deletions surface_vectorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,13 +710,18 @@ Surface_vectorial::PathFinder Surface_vectorial::make_path_finder(
// risetime at G0 + horizontal distance G0 + plunge G1 ==
// travel time at G1
// The horizontal G0 move is for the maximum of the X and Y coordinates.
// We'll assume that G0 Z is 50inches/minute and G0 X or Y is 100 in/min, taken from Nomad Carbide 883.
const auto vertical_distance = mill->zsafe - mill->zwork;
const auto max_manhattan = std::max(std::abs(a.x() - b.x()), std::abs(a.y() - b.y()));
const double horizontalG1speed = mill->feed;
const double vertG1speed = mill->vertfeed;
const double g0_time = vertical_distance/mill->g0_vertical_speed + max_manhattan/mill->g0_horizontal_speed + vertical_distance/vertG1speed;
const double max_g1_distance = g0_time * horizontalG1speed;
// The time saved by milling would be g0_time - g1_distance/g1_horizontal_speed.
// The extra wear on the mill is g1_distance.
// Wear is limited by the backtrack value (in distance/time).
// g1_distance/time_saved < backtrack => g1_distance < backtrack/time_saved
const double max_g1_distance = std::isinf(mill->backtrack) ?
g0_time * horizontalG1speed :
mill->backtrack*g0_time / (1 + mill->backtrack/horizontalG1speed);
return path_finding_surface.find_path(a, b, max_g1_distance, make_optional(mill->path_finding_limit));
};
}
Expand All @@ -736,7 +741,13 @@ Surface_vectorial::PathFinderRingIndices Surface_vectorial::make_path_finder_rin
const double horizontalG1speed = mill->feed;
const double vertG1speed = mill->vertfeed;
const double g0_time = vertical_distance/mill->g0_vertical_speed + max_manhattan/mill->g0_horizontal_speed + vertical_distance/vertG1speed;
const double max_g1_distance = g0_time * horizontalG1speed;
// The time saved by milling would be g0_time - g1_distance/g1_horizontal_speed.
// The extra wear on the mill is g1_distance.
// Wear is limited by the backtrack value (in distance/time).
// g1_distance/time_saved < backtrack => g1_distance < backtrack/time_saved
const double max_g1_distance = std::isinf(mill->backtrack) ?
g0_time * horizontalG1speed :
mill->backtrack*g0_time / (1 + mill->backtrack/horizontalG1speed);
return path_finding_surface.find_path(a, b, max_g1_distance, mill->path_finding_limit, search_key);
};
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions testing/gerbv_example/backtrack_0/expected/outp2_masked_front.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e7c1175

Please sign in to comment.