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

Add backtracking feature #427

Merged
merged 8 commits into from
Jun 16, 2020
Merged

Add backtracking feature #427

merged 8 commits into from
Jun 16, 2020

Conversation

eyal0
Copy link
Contributor

@eyal0 eyal0 commented Jun 12, 2020

--backtrack does a greedy search among line segments looking for
vertices that have:

  • odd number of edges
  • more outbound edges than inbound and bidirectional
  • more inbound edges than outbound and bidirectional

For each one, it finds the nearest other vertex for which duplicating
edges would create a euler circuit. Edges are only added if milling
them is faster than retracting, moving, and lowering.

@eyal0
Copy link
Contributor Author

eyal0 commented Jun 12, 2020

Before:
image

After:
image

Notice how the length milled has become longer but there are no more retracts. Each one was calculated so that it was only added if milling was faster than retract+g0+lower.

@eyal0
Copy link
Contributor Author

eyal0 commented Jun 12, 2020

Here are the paths that are doubled:

image

It's hard for me to tell if those were good choices. I just have to trust that the algorithm did it right. Definitely we could have made different choices if we didn't use a greedy algorithm but this is a good start. Maybe in the future I can use an algorithm that searches the space of choices, like a minimum weight matching. Code for that is the Blossom V algorithm.

@eyal0 eyal0 force-pushed the backtrack branch 4 times, most recently from a18c3e3 to fcb681b Compare June 16, 2020 03:32
@coveralls
Copy link
Collaborator

coveralls commented Jun 16, 2020

Coverage Status

Coverage increased (+0.4%) to 67.951% when pulling 11c837a on eyal0:backtrack into 4ad5465 on pcb2gcode:master.

backtrack does a greedy search among line segments looking for
vertices that have:

* odd number of edges
* more outbound edges than inbound and bidirectional
* more inbound edges than outbound and bidirectional

For each one, it finds the nearest other vertex for which duplicating
edges would create a euler circuit.  Edges are only added if milling
them is faster than retracting, moving, and lowering.
@eyal0 eyal0 force-pushed the backtrack branch 2 times, most recently from 7256a93 to 11c837a Compare June 16, 2020 17:12
@eyal0
Copy link
Contributor Author

eyal0 commented Jun 16, 2020

Blossom V requires undirected edges as far as I can tell so it won't suit.

As a test, after enabling backtrack for all of the integration tests, I had pcb2gcode output all the segments that it's going to mill. The only difference with/without backtrack is that there are segments that get milled more than once. However, there are no new segments being milled. Also, the direction of segments that have a required direction is maintained. So that's convincing.

@eyal0 eyal0 merged commit c31a338 into pcb2gcode:master Jun 16, 2020
@eyal0 eyal0 deleted the backtrack branch June 16, 2020 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants