Compare commits

...

5 Commits

7 changed files with 129 additions and 7 deletions

2
.gitignore vendored
View File

@ -4,3 +4,5 @@
*.mkv
test_svg
test_png
draw.sqlite
.env

9
ax.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
axicli -f /home/ubuntu/plotter/axidraw_conf_robothouse_a3.py \
--report_time \
--model 2 \
--pen_pos_up 20 \
--pen_pos_down 60 \
--output_file /home/ubuntu/progress.svg \
"${@}"

View File

@ -1,5 +1,35 @@
#!/bin/bash
if [ -f ".env" ]; then
source .env
fi
if [[ "${DB_FILE}" != "" ]]; then
FULL_DATABASE=`realpath "${DB_FILE}"`
else
FULL_DATABASE=`realpath "./draw.sqlite"`
fi
db () {
sqlite3 "${FULL_DATABASE}" "${1}"
}
dbSetup () {
cat "./sql/setup.sql" | sqlite3 "${FULL_DATABASE}"
}
hashStr () {
echo -n "${1}" | sha256sum | awk '{print $1}'
}
hashFile () {
sha256sum "${1}" | awk '{print $1}'
}
uuid () {
uuidgen | tr "[:upper:]" "[:lower:]"
}
askContinue () {
echo "${1}"
echo "Are you ready to continue? (yes/no)"
@ -11,3 +41,14 @@ askContinue () {
exit 1
fi
}
axdraw () {
file=$(realpath "${1}")
echo "FILE:${file}"
if [[ "${PEN}" != "" ]]; then
echo "PEN:${PEN}"
fi
echo "START:$(date '+%s')"
ax "${1}"
echo "END:$(date '+%s')"
}

View File

@ -15,6 +15,8 @@ if [[ "${1}" == "" ]]; then
exit 1
fi
dbSetup
FRAMES=$(realpath "${1}")/
END=-1
@ -48,6 +50,7 @@ for svg in "${FRAMES}"*.svg ; do
i=$((i+1))
continue
fi
filename=`basename "${svg}"`
name=`echo "${filename}" | cut -d'.' -f1`
num=`echo "${name}" | awk -F'_' '{print $(NF)}'`
@ -57,7 +60,7 @@ for svg in "${FRAMES}"*.svg ; do
number=`mktemp`.svg
node ./numbers/ -n "${num}" -o "${number}"
ax "${number}"
ax "${svg}"
axdraw "${svg}" | bash ./log.sh
rm -f "${number}"
bash position.sh reset

50
log.sh Normal file
View File

@ -0,0 +1,50 @@
#!/bin/bash
source ./common.sh
loglines="$(cat /dev/stdin)"
id=$(uuid)
file=$(echo "${loglines}" | grep 'FILE:' | awk -F'FILE:' '{print $2}')
starttime=$(echo "${loglines}" | grep 'START:' | awk -F':' '{print $2}')
endtime=$(echo "${loglines}" | grep 'END:' | awk -F':' '{print $2}')
pen=$(echo "${loglines}" | grep 'PEN:' | awk -F':' '{print $2}')
drawn=$(echo "${loglines}" | grep 'Length of path drawn' | awk -F':' '{print $2}' | awk '{print $1}')
moved=$(echo "${loglines}" | grep 'Total distance moved' | awk -F':' '{print $2}' | awk '{print $1}')
hash=$(hashFile "${file}")
info=$(svginfo "${file}")
paths=$(echo "$info" | grep -m 1 'number of paths' | awk -F': ' '{print $2}')
total=$(echo "$info" | grep 'total path length' | awk -F': ' '{print $2}')
ratio=$(echo "$info" | grep 'pen move ratio' | awk -F': ' '{print $2}')
bboxclean=$(echo "$info" | grep 'bbox' | awk -F ')' '{print $1}' | awk -F'(' '{print $2}')
xmin=$(echo "$bboxclean" | awk -F', ' '{print $1}')
xmax=$(echo "$bboxclean" | awk -F', ' '{print $2}')
ymin=$(echo "$bboxclean" | awk -F', ' '{print $3}')
ymax=$(echo "$bboxclean" | awk -F', ' '{print $4}')
if [[ "${pen}" != "" ]]; then
pen="'${pen}'"
else
pen=null
fi
query="INSERT OR IGNORE INTO svg (id, file, drawn, moved, starttime, endtime, pen, hash, paths, total, ratio, xmin, xmax, ymin, ymax) VALUES (\
'$id', \
'$file',\
$drawn,\
$moved,\
$starttime,\
$endtime,\
$pen,\
'$hash',\
$paths,\
$total,\
$ratio,\
$xmin,\
$xmax,\
$ymin,\
$ymax
);"
db "${query}"
echo "${loglines}"

17
sql/setup.sql Normal file
View File

@ -0,0 +1,17 @@
CREATE TABLE IF NOT EXISTS svg (
id TEXT PRIMARY KEY,
file TEXT,
starttime INTEGER,
endtime INTEGER,
drawn REAL,
moved REAL,
paths INTEGER,
total REAL,
ratio REAL,
xmin REAL,
xmax REAL,
ymin REAL,
ymax REAL,
pen TEXT,
hash TEXT
);

View File

@ -28,11 +28,11 @@ mkdir -p "${OUTPUT}"
FRAMERATE=12
WIDTH=404
HEIGHT=374
DOTSIZE=6
MAXGENERATIONS=50
MAXPARTICLES=900
MINDOTSIZE=0.5
LINE=0.5
DOTSIZE=2
MAXGENERATIONS=25
MAXPARTICLES=1200
MINDOTSIZE=1.5
LINE=1.5
FILL=true
MODE="stipple" #stipple/tsp