-
Notifications
You must be signed in to change notification settings - Fork 1
/
NewBot.rb
executable file
·165 lines (152 loc) · 3.57 KB
/
NewBot.rb
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#require './BotRit.rb'
#require './BotRot.rb'
require './BotJax.rb'
$rimmer = 0.1
class Bot
$bitwidth = 0.125
$halfwidth = $bitwidth/2
TIERATE = 0.12
@@lipp = 0.05
@@pentrate = 30
@@feedrate = 40
def initialize(starx, stary)
@heighchub = @heigh / 2.0
@duxulate =Integer(@depth / TIERATE)
@starx = starx
@stary = stary
@curxo = starx
end
def retrax(z)
printf "G0 Z%5.3f\n",z
end
def retract
retrax(0.1)
end
def penetrate(z)
printf "G1 Z%5.3f F%d\n", z, @@pentrate
end
def cutoPoint(x,y)
printf "G1 X%5.3f Y%5.3f F%d\n", x, y, @@feedrate
end
def skimtoPoint(x,y,z)
retrax(z)
printf "G0 X%5.3f Y%5.3f\n", x, y
end
def gotoPoint(x,y)
skimtoPoint(x,y,0.1)
end
def dwellus(tparm)
printf "G4 P%5.3f \n",tparm
end
def drillus(x,y,zstart,zdepth)
skimtoPoint(x,y,zstart+0.1)
penetrate(zdepth)
dwellus(0.5)
end
#include BotRit
#include BotRot
include BotJax
def duxo()
@curxo += $halfwidth
dux(@curxo, @stary-getBrot, @curxo, @stary+getBrot, 0, 0-@depth, @duxulate)
@curxo += $halfwidth
return @curxo
end
def duxong(pranska)
incro = (Float(@depth) / Float(@duxulate))
skimtoPoint(pranska[0][0],pranska[0][1],0.1)
for i in 1..@duxulate do
penetrate(0-(incro * i))
if (i.divmod(2)[1] != 0) then
pranska.each {|x| cutoPoint(x[0],x[1])} else
pranska.reverse.each {|x| cutoPoint(x[0],x[1])}
end
end
end
def getBrot()
return @heighchub + $halfwidth + @@lipp
end
def getTopPranska()
pranska = [[@starx,@stary+getBrot], [@curxo,@stary+getBrot]]
end
def getBotPranska()
pranska = [[@starx,@stary-getBrot], [@curxo,@stary-getBrot]]
end
def ducatop()
brot = getBrot()
dux(@starx,@stary+brot,@curxo,@stary+brot,0,0-@depth,@duxulate)
end
def ducabot()
brot = getBrot()
dux(@starx,@stary-brot,@curxo,@stary-brot,0,0-@depth,@duxulate)
end
def numerize
end
def getWido
end
end
def indostutterat(clasz)
xarg = 1
unless ARGV[1].nil? then xarg = Integer(ARGV[1]) end
browblank = []
mystuff = clasz.new(0,0)
mystuff = clasz.new(mystuff.duxo(), 0)
for j in 1..xarg do
browblank.push(mystuff)
mystuff.boxo()
mystuff = clasz.new(mystuff.duxo(),0)
end
browblank.reverse.each {|y| y.ducabot}
browblank.each {|y| y.ducatop}
printf "G0 Z0.1\n"
end
def stutterat(clasz)
xarg = yarg = 1
unless ARGV[0].nil? then yarg = Integer(ARGV[0]) end
unless ARGV[1].nil? then xarg = Integer(ARGV[1]) end
if yarg == 0 then return indostutterat(clasz) end
curyo = clasz.new(0,0).getBrot #* (yarg-1)
curyop = curyo + 0.152 + (2*curyo*(yarg-1)) + (yarg*$rimmer)
curyob = 0 - curyop
rowse = []
toprowse = []
botrowse = []
for i in 1..yarg do
curxo = 0
trowblank = []
mystuff = clasz.new(curxo,curyop)
mystuff = clasz.new(mystuff.duxo(), curyop)
if i == 1 then mystuff.numerize end
for j in 1..xarg do
trowblank.push(mystuff)
mystuff.boxo()
mystuff = clasz.new(mystuff.duxo(), curyop)
end
#toprowse.push(rowblank)
browblank = []
mystuff = clasz.new(curxo,-curyop)
mystuff = clasz.new(mystuff.duxo(),-curyop)
for j in 1..xarg do
browblank.push(mystuff)
mystuff.boxo()
mystuff = clasz.new(mystuff.duxo(),-curyop)
end
trowblank.each {|y| y.ducatop}
trowblank.reverse.each {|y| y.ducabot}
browblank.reverse.each {|y| y.ducabot}
browblank.each {|y| y.ducatop}
#botrowse.push(rowblank)
curyop -= mystuff.getBrot
curyop -= mystuff.getBrot
curyop -= $rimmer
end
printf "G0 Z0.1\n"
#toprowse.reverse.each {|x|
# x.each {|y| y.ducatop}
# x.reverse.each {|y| y.ducabot}
#}
#botrowse.reverse.each {|x|
# x.reverse.each {|y| y.ducabot}
# x.each {|y| y.ducatop}
#}
end