-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcar
executable file
·128 lines (116 loc) · 2.99 KB
/
car
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
#!/bin/bash
function nothing() {
echo "usage:"
echo "car -- Simplified operation"
echo "| ./car init -- init basic folder"
echo "| ./car help -- help infomation"
echo "| ./car camera -- adjust car camera by computer"
echo "| ./car start -- control car by computer"
echo "| ./car check -- check if picture is empty"
echo "| ./car train -- train network"
echo "| ./car auto -- control car by network"
echo "| ./car clean -- clean useless image and model"
echo "V"
}
function help() {
nothing
echo " _____________________________ "
echo " | |"
echo " | q w p |"
echo " | a d h j k l |"
echo " | |"
echo " | |"
echo " | _____ |"
echo " | |space| |"
echo " | ----- |"
echo " |_____________________________|"
echo ""
echo " w: car start, adjust direction to forward"
echo " a: car start, adjust direction to left"
echo " d: car start, adjust direction to right"
echo " h: car camera, adjust camera left"
echo " j: car camera, adjust camera down"
echo " k: car camera, adjust camera up"
echo " l: car camera, adjust camera right"
echo " p: car auto, stop toy-car"
echo " q: car start/auto, end program"
echo "space: car start/auto, forward then stop; stop then forward"
}
function init() {
if [ ! -d "html/data/a" ]; then
mkdir -p html/data/a
fi
if [ ! -d "html/data/d" ]; then
mkdir -p html/data/d
fi
if [ ! -d "html/data/w" ]; then
mkdir -p html/data/w
fi
if [ ! -d "network/model" ]; then
mkdir -p network/model
fi
}
function camera() {
python3 ./control/CameraAdjust.py
}
function start() {
echo "car start..."
init
python3 ./control/Car.py
}
function check() {
python3 ./tools/check.py ./html/data/
}
function train() {
echo "network train..."
python3 ./network/Train.py
}
function auto() {
echo "car drive..."
python3 ./network/Car.py
}
function clean() {
echo "remove data..."
if [ ! -f "./html/data/" ]; then
rm -rf ./html/data/*
fi
echo "remove model..."
if [ ! -f "./network/model/" ]; then
rm -rf ./network/model/*
fi
echo "remove __pycache__"
if [ ! -f "./control/__pycache__" ]; then
rm -rf ./control/__pycache__
fi
if [ ! -f "./network/__pycache__" ]; then
rm -rf ./network/__pycache__
fi
}
function main() {
echo $cmd
if [ -z $cmd ]; then
nothing
exit 1
fi
if [ $cmd == 'help' ]; then
help
elif [ $cmd == 'init' ]; then
init
elif [ $cmd == 'camera' ]; then
camera
elif [ $cmd == 'start' ]; then
start
elif [ $cmd == 'check' ]; then
check
elif [ $cmd == 'train' ]; then
train
elif [ $cmd == 'auto' ]; then
auto
elif [ $cmd == 'clean' ]; then
clean
else
./car
fi
}
cmd=$1
main