Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use backtracking limit in path_finding #573

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.