-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcalibrate
More file actions
executable file
·153 lines (131 loc) · 3.69 KB
/
calibrate
File metadata and controls
executable file
·153 lines (131 loc) · 3.69 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
#! /bin/bash
echo
echo "COMMAND : $0 $@ # FireREST/FireFUSE visual calibration utility"
function help() {
echo "SYNOPSIS: fire/calibrate [-hr]"
echo "EXAMPLE : Find maximum feed rate"
echo " : fire/calibrate -f"
echo "EXAMPLE : Compute pixels/mm"
echo " : fire/calibrate -p"
echo "EXAMPLE : Compute x,y error offsets"
echo " : fire/calibrate -o"
echo "EXAMPLE : Compute pixels per millimeter of travel"
echo " : fire/calibrate -r"
echo "EXAMPLE : Print this documentation:"
echo " : fire/calibrate -h"
}
if [ "$1" == "" ] || [ "$1" == "-h" ]; then help; exit 0; fi
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
Z=1
for X in `seq -17.5 5 17.5`
do
for Y in `seq -17.5 5 17.5`
do
imageAt X${X}Y${Y}Z${Z}
done
done
Z=-1
for X in `seq -17.5 5 17.5`
do
for Y in `seq -17.5 5 17.5`
do
imageAt X${X}Y${Y}Z${Z}
done
done
echo "SUCCESS : calibrated"
exit 0;
fi
if [ "$1" == "-p" ]; then
echo "STATUS : taking images for calibrating pixels per mm"
gcode G28Z0M400 "Homing"
sleep 3
gcode G0Z0Y0Z0M400 "Moving to origin"
sleep 5
for i in `seq 1 1 3`
do
sleep 1
imageAt X10Y10Z0
imageAt X10Y10Z0
mv /var/firefuse/calibration/X10Y10Z0.jpg /var/firefuse/calibration/X10Y10Z0-$i.jpg
gcode G0Z0Y0Z0M400 "Moving to origin"
sleep 1
imageAt X10Y10Z0.1
imageAt X10Y10Z0.1
mv /var/firefuse/calibration/X10Y10Z0.1.jpg /var/firefuse/calibration/X10Y10Z0.1-$i.jpg
done
echo "SUCCESS : completed"
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