mirror of
https://github.com/eddyem/pusirobot.git
synced 2025-12-06 18:45:12 +03:00
38 lines
650 B
Bash
Executable File
38 lines
650 B
Bash
Executable File
#!/bin/bash
|
|
|
|
function move(){
|
|
./steppermove -I4 $*
|
|
}
|
|
|
|
if [ $# -ne 1 ]; then
|
|
echo "Usage: $0 Nposition (enumeration from 0)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ $1 -lt 0 -o $1 -gt 5 ]; then
|
|
echo "Turet position should be from 0 to 5" >&2
|
|
exit 2
|
|
fi
|
|
|
|
LAST=-1
|
|
[ -f lastpos ] && LAST=$(cat lastpos)
|
|
|
|
eval "$(move -s250 -m50)"
|
|
|
|
DIFF=$((CURENCODER - LAST))
|
|
ABS=${DIFF#-} # absoulte value
|
|
|
|
if [ $ABS -gt 3 ]; then # goto zero if last position differs more then for 3 from current
|
|
move -cE1 -r-1000
|
|
move -wcA
|
|
move -0
|
|
fi
|
|
|
|
move -Fa $((683*$1))
|
|
move -w
|
|
|
|
sleep 1 # wait for stopping
|
|
eval "$(move)"
|
|
echo $CURENCODER > lastpos
|
|
echo "Current encoder position: $CURENCODER"
|