-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.py
143 lines (105 loc) · 3.89 KB
/
basic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from pyroland.cmd import RMDCommander
from pyroland.mill import RolandMill
import numpy as np
class EnhancedCommand(RMDCommander):
def fillInside(self, xyMin: tuple, xyMax: tuple, toolSize: float, zHeight: float):
halfTool = toolSize / 2
xyMin = (v + halfTool for v in xyMin)
xyMax = (v - halfTool for v in xyMax)
# Box out the move to avoid leaving tails later
self.fillRect(xyMin, xyMax, toolSize, zHeight)
def fillRect(self, xyMin: tuple, xyMax: tuple, toolSize: float, zHeight: float):
# Determine the number of passes
# Compute the x starting points
# move to
# ^Y move to x
xMin, yMin = xyMin
xMax, yMax = xyMax
dx = xMax - xMin
dy = yMax - yMin
# Box out the move to avoid leaving tails later
self.strokeRect(xyMin, xyMax, zHeight)
# Compute the line offsets to work in
passes = int(np.ceil(dx / (toolSize*0.9)))
offsets = np.linspace(xMin, xMax, passes)
for n, xOffset in enumerate(offsets):
if n % 2 == 0:
self.absXYZ(xOffset, yMin, zHeight)
self.absXYZ(xOffset, yMax, zHeight)
else:
self.absXYZ(xOffset, yMax, zHeight)
self.absXYZ(xOffset, yMin, zHeight)
def strokeRect(self, xyMin: tuple, xyMax: tuple, zHeight: float):
xMin, yMin = xyMin
xMax, yMax = xyMax
self.absXY(xMin, yMin)
self.absXYZ(xMin, yMin, zHeight)
self.absXYZ(xMax, yMin, zHeight)
self.absXYZ(xMax, yMax, zHeight)
self.absXYZ(xMin, yMax, zHeight)
self.absXYZ(xMin, yMin, zHeight)
def strokeInside(self, xyMin: tuple, xyMax: tuple, toolSize: float, zHeight: float):
# Determine the number of passes
# Compute the x starting points
# move to
# ^Y move to x
halfTool = toolSize / 2
xyMin = (v + halfTool for v in xyMin)
xyMax = (v - halfTool for v in xyMax)
# Box out the move to avoid leaving tails later
self.strokeRect(xyMin, xyMax, zHeight)
mill = RolandMill()
def cutting_board_outline():
edge_min = (-190, -290)
edge_max = (151, 105)
bit_size = 9.5 - 1.63
cmd = EnhancedCommand()
with cmd.cutting_context(10000, 40):
for z in np.linspace(-58, -86, 30):
cmd.strokeInside(edge_min, edge_max, bit_size, z)
cmd.liftZ()
mill.runCommand(cmd)
mill.waitUntilDone()
# Rounded inlay
def inlay():
edge_min = (-170, -270)
edge_max = (131, 85)
bit_size = 9.5 - 1.63
z = -56
cmd = EnhancedCommand()
with cmd.cutting_context(10000, 40):
cmd.strokeInside(edge_min, edge_max, bit_size, z)
cmd.liftZ()
mill.runCommand(cmd)
mill.waitUntilDone()
def face():
bit_size = 9.5
edge_min = (-200.895, -290.585)
edge_max = (130.105, 95.415)
cmd = EnhancedCommand()
cmd.liftZ()
with cmd.cutting_context(10000, 20):
for zHeight in [-44.5]:
cmd.fillRect(edge_min, edge_max, bit_size, zHeight)
mill.runCommand(cmd)
def pockets():
bit_size = 9.5
edge_min = (-205.895, -295.585)
edge_max = (135.105, 99.415)
edge_min = tuple(v + 30 for v in edge_min)
edge_max = tuple(v - 30 for v in edge_max)
x1, x2, x3, x4 = np.linspace(edge_min[0], edge_max[0], 4)
y1, y2, y3, y4 = np.linspace(edge_min[1], edge_max[1], 4)
cmd = EnhancedCommand()
with cmd.cutting_context(10000, 40):
for z in np.linspace(-50, -75, 10):
cmd.liftZ()
cmd.fillRect((x1, y1), (x4, y2), bit_size, z)
cmd.liftZ()
cmd.fillRect((x1, y3), (x4, y4), bit_size, z)
cmd.liftZ()
cmd.fillRect((x1, y2-5), (x2, y3+5), bit_size, z)
cmd.liftZ()
cmd.fillRect((x3, y2-5), (x4, y3+5), bit_size, z)
mill.runCommand(cmd)
pockets()