-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcenter
More file actions
222 lines (192 loc) · 4.54 KB
/
center
File metadata and controls
222 lines (192 loc) · 4.54 KB
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#! /bin/bash
echo
echo "COMMAND : $0 $@ # FireREST/FireFUSE visual centering"
function help() {
echo "SYNOPSIS: fire/$0 [-h]"
echo "EXAMPLE : Print this documentation:"
echo " : fire/$0 -h"
}
if [ "$1" == "" ] || [ "$1" == "-h" ]; then help; exit 0; fi
# 0,0 157 121 -43, -79
# 0,1 162 119 -38, -81
# 0,-1 162 119 -38, -81
# 0,0 157 122 -43, -78
# 0,1 162 120
# 1,0 161 128
# 2,0 164 133
# 3,0 168 138
# 4,0 171 144
# 5,0 174 150
# 13,0 203 196
# 12.5,0 201 193
# 12.5,-1 196 196
# 13,-1 197 198
# 13.5,-1 199 202
# 14,-.5 203 202
# 13.8,-.6 202 202
# 13.7,-.6 202 202
# 13.6,-.6 202 200
# 13.4,-.6 202 200
# 1,1 165 122
# 2,1 169 130
# 3,1 173 136
# 4,1 176 141
exit 0
IMAGES=/var/firefuse/calibration
GCODEFIRE=/dev/firefuse/sync/cnc/marlin/gcode.fire
if [ ! -e $GCODEFIRE ]; then
echo "ERROR : FireFUSE serial connection to Marlin is unavailable"
echo "TRY : See /var/log/firefuse.log for details"
exit -1
fi
function gcode() {
if [ "$2" != "" ]; then echo "STATUS : $2"; fi
echo "GCODE : $1"
echo "$1" > $GCODEFIRE
RC=$?; if [ $RC -ne 0 ]; then echo "ERROR : $RC"; exit -1; fi
return $RC
}
function imageAt() {
echo "IMAGE : $1"
gcode G0$1M400
RC=$?; if [ $RC -ne 0 ]; then echo "ERROR : echo $GCODE > $GCODEFIRE => $RC"; exit -1; fi
cp /dev/firefuse/sync/cv/1/camera.jpg $IMAGES/$1.jpg
RC=$?; if [ $RC -ne 0 ]; then echo "ERROR : $RC"; exit -1; fi
}
function calcoffset() {
firesight -ji 0 -p FireSight/json/calcOffset.json -Dtemplate=$IMAGES/$1 -i $IMAGES/$2
}
function calcoffsetAt() {
RESULT=`firesight -ji 0 -p FireSight/json/calcOffset.json -Dtemplate=$IMAGES/$2.jpg -i $IMAGES/$1.jpg`
RC=$?; if [ $RC -ne 0 ]; then echo "ERROR : $RC"; exit -1; fi
#echo "RESULT : $RESULT"
DX=`echo $RESULT | grep -o -E "dx.:[-0-9.+]+" | grep -o -E "[-0-9.+]+"`
DY=`echo $RESULT | grep -o -E "dy.:[-0-9.+]+" | grep -o -E "[-0-9.+]+"`
#echo "STATUS : dx=$DX dy=$DY"
}
function resolutionAt() {
imageAt X0Y0$1
imageAt X-1Y0$1
imageAt X1Y0$1
imageAt X0Y-1$1
imageAt X0Y1$1
calcoffsetAt X-1Y0$1 X1Y0$1
EQN="scale=3;sqrt(($DX)^2+($DY)^2)/2"
echo "STATUS : resolution (-1,0,$1):(-1,-1,$1) "`bc <<< $EQN`
calcoffsetAt X0Y-1$1 X0Y1$1
EQN="scale=3;sqrt(($DX)^2+($DY)^2)/2"
echo "STATUS : resolution (0,-1,$1):(0,1,$1) "`bc <<< $EQN`
}
if [ "$1" == "-r" ]; then
gcode G28Z0M400 "Homing"
sleep 5
gcode G0Z0Y0Z0M400 "Moving to origin"
sleep 5
resolutionAt Z0
echo "SUCCESS : calibrated"
exit 0;
fi
if [ "$1" == "-o" ]; then
gcode G28Z0M400 "Homing"
sleep 5
#gcode M203X10000Y10000Z10000G0Z0Y0Z0F4000M400 "Moving to origin"
gcode G0Z0Y0Z0M400 "Moving to origin"
sleep 5
imageAt X-20Y-20Z0
imageAt X-15Y-20Z0
imageAt X-10Y-20Z0
imageAt X-05Y-20Z0
imageAt X0Y-20Z0
imageAt X5Y-20Z0
imageAt X10Y-20Z0
imageAt X15Y-20Z0
imageAt X20Y-20Z0
imageAt X-20Y-15Z0
imageAt X-15Y-15Z0
imageAt X-10Y-15Z0
imageAt X-05Y-15Z0
imageAt X0Y-15Z0
imageAt X5Y-15Z0
imageAt X10Y-15Z0
imageAt X15Y-15Z0
imageAt X20Y-15Z0
imageAt X-20Y-10Z0
imageAt X-15Y-10Z0
imageAt X-10Y-10Z0
imageAt X-05Y-10Z0
imageAt X0Y-10Z0
imageAt X5Y-10Z0
imageAt X10Y-10Z0
imageAt X15Y-10Z0
imageAt X20Y-10Z0
imageAt X-20Y-5Z0
imageAt X-15Y-5Z0
imageAt X-10Y-5Z0
imageAt X-05Y-5Z0
imageAt X0Y-5Z0
imageAt X5Y-5Z0
imageAt X10Y-5Z0
imageAt X15Y-5Z0
imageAt X20Y-5Z0
imageAt X-20Y0Z0
imageAt X-15Y0Z0
imageAt X-10Y0Z0
imageAt X-05Y0Z0
imageAt X0Y0Z0
imageAt X5Y0Z0
imageAt X10Y0Z0
imageAt X15Y0Z0
imageAt X20Y0Z0
imageAt X-20Y5Z0
imageAt X-15Y5Z0
imageAt X-10Y5Z0
imageAt X-05Y5Z0
imageAt X0Y5Z0
imageAt X5Y5Z0
imageAt X10Y5Z0
imageAt X15Y5Z0
imageAt X20Y5Z0
imageAt X-20Y10Z0
imageAt X-15Y10Z0
imageAt X-10Y10Z0
imageAt X-05Y10Z0
imageAt X0Y10Z0
imageAt X5Y10Z0
imageAt X10Y10Z0
imageAt X15Y10Z0
imageAt X20Y10Z0
imageAt X-20Y15Z0
imageAt X-15Y15Z0
imageAt X-10Y15Z0
imageAt X-05Y15Z0
imageAt X0Y15Z0
imageAt X5Y15Z0
imageAt X10Y15Z0
imageAt X15Y15Z0
imageAt X20Y15Z0
imageAt X-20Y20Z0
imageAt X-15Y20Z0
imageAt X-10Y20Z0
imageAt X-05Y20Z0
imageAt X0Y20Z0
imageAt X5Y20Z0
imageAt X10Y20Z0
imageAt X15Y20Z0
imageAt X20Y20Z0
echo "SUCCESS : calibrated"
exit 0;
fi
if [ "$1" == "-f" ]; then
echo "STATUS : calibrating feed rate"
gcode M203X10000Y10000Z10000
gcode G28Z0 "Homing"
sleep 5
gcode G0Z0Y0Z0F9000 "Moving to origin"
gcode M400
image X0Y0Z0
cp /var/firefuse/calibration/X0Y0Z0.jpg /var/firefuse/calibration/X0Y0Z0-a.jpg
gcode G0X50
gcode M400
image X0Y0Z0
calcoffset X0Y0Z0 X0Y0Z0-a
fi