forked from RoboFEI/RoboFEI-HT_2019
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·270 lines (252 loc) · 6.67 KB
/
setup.sh
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
blue='\e[0;34m'
NC='\e[0m' # No Color
red='\e[0;31m'
green='\e[0;32m'
re='^[0-9]+$' # Is number
echo
echo "This script will configure RoboFEI-HT software"
echo
if [ -z "$1" ]; then
read -p "Continue? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]
then
exit 1
fi
fi
if [[ "$1" == "S" || "$2" == "S" || "$3" == "S" || "$1" == "s" || "$2" == "s" || "$3" == "s" ]]; then
MODE="S"
else
if [[ "$1" == "R" || "$2" == "R" || "$3" == "R" || "$1" == "r" || "$2" == "r" || "$3" == "r" ]]; then
MODE="R"
else
echo "Will this setup be used for Simulation or Real robot (S/R)? "
read MODE
fi
fi
if [ $MODE == "S" ] || [ $MODE == "s" ];
then
echo -e "${blue} ***** SIMULATION MODE ***** ${NC}"
if ! [[ $1 =~ $re || $2 =~ $re ]] ; then
read -p "How many robots do you want to compile? "
echo
else
if [[ $1 =~ $re ]]; then
REPLY=$1
fi
if [[ $2 =~ $re ]]; then
REPLY=$2
fi
fi
echo
if [ $REPLY == 1 ]; then
echo -e "${blue} AI ${NC}"
echo -e "${blue} Installing serial ${NC}"
cd AI/IMU/serial
mkdir build
cd build
cmake ../
make all
sudo make install
cd ../../..
echo
echo -e "${blue} Installing whole software ${NC}"
cd AI
mkdir build
cd build
cmake ../
make all
make install
cd ..
cd Control/Data
sed -i -e 's/no_player_robofei = [0-30]*/no_player_robofei = 1 /' config.ini
cd ../../..
fi
if [ $REPLY -gt 1 ]; then
echo 'starting ' $REPLY ' robots'
cd AI
mkdir build
cd build
cmake ../
make all
make install
cd ..
cd Control/Data
sed -i -e 's/no_player_robofei = [0-30]*/no_player_robofei = 1 /' config.ini
cd ../../..
for ((i = 2; i <= $REPLY; i++)); do
cp -ar AI AI$i
cd AI$i/Control/Data
sed -i -e 's/no_player_robofei = [0-30]*/no_player_robofei = '$i'/' config.ini
cd ../../..
done
fi
for ((i = 1; i <= "$REPLY"; i++)); do
if [ $i == 1 ]; then
cd AI
else
cd AI$i
fi
echo -e "${blue} Installing whole software ${NC}"
mkdir build
cd build
cmake ../
make all
make install
cd ../..
done
else
echo -e "${blue} ***** REAL MODE ***** ${NC}"
sleep 1
echo -e "${blue} Installing serial ${NC}"
cd AI/IMU/serial
mkdir build
cd build
cmake ../
make all
sudo make install
cd ../../..
echo -e "${blue} Installing whole software ${NC}"
cd AI
mkdir build
cd build
cmake ../
make all
make install
cd ../../
sudo echo -e "Creating rules for recognizing device${red} IMU${NC}"
cat <<EOF > 41-ftdi-imu.rules
KERNEL=="ttyUSB?", SUBSYSTEMS=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", MODE="0777", SYMLINK+="robot/imu"
KERNEL=="ttyUSB?", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001",ATTRS{serial}=="A9K3FL1T" MODE="0777", SYMLINK+="robot/imu"
EOF
chmod +x 41-ftdi-imu.rules
cat <<EOF > 80-latency_USB.rules
ACTION=="add", SUBSYSTEM=="usb-serial", DRIVER=="ftdi_sio", ATTR{latency_timer}="1"
EOF
sudo echo -e "Copying file${blue} 41-ftdi-imu.rules 80-latency_USB.rules${NC} to ${green}/etc/udev/rules.d${NC}"
sudo cp 41-ftdi-imu.rules /etc/udev/rules.d
sudo cp 80-latency_USB.rules /etc/udev/rules.d
rm 41-ftdi-imu.rules
rm 80-latency_USB.rules
sudo echo -e "Creating rules for recognizing devices${red} Servo${NC}"
sudo python ./AI/Control/Linux/device/renamePort.py
sudo echo "Restarting udev"
sudo service udev restart
cd AI/Control/Data/
sudo echo "Starting robots configuration"
if ! [[ $1 =~ $re || $2 =~ $re || $3 =~ $re ]] ; then
sudo echo "Insert robot number: "
read NUM
else
if [[ $1 =~ $re ]]; then
NUM=$1
fi
if [[ $2 =~ $re ]]; then
NUM=$2
fi
if [[ $3 =~ $re ]]; then
NUM=$3
fi
fi
case $NUM in
1) sudo echo "Robot 1 ..."
if [[ "$1" == "G" || "$2" == "G" || "$3" == "G" || "$1" == "g" || "$2" == "g" || "$3" == "g" ]]; then
CONF="y"
else
if [[ "$1" == "F" || "$2" == "F" || "$3" == "F" || "$1" == "f" || "$2" == "f" || "$3" == "f" ]]; then
CONF="n"
else
sudo echo "Artificial Grass [Y/N]: "
read CONF
fi
fi
if [ "$CONF" = "y" ]
then
ln -sf ../../conf_robos/01/grama/* .
ln -sf ../../conf_robos/01/vision/* ../../Vision/Data
echo "grass files copied!"
elif [ "$CONF" = "n" ]
then
ln -sf ../../conf_robos/01/chao/* .
ln -sf ../../conf_robos/01/vision/* ../../Vision/Data
echo "flat floor files copied!"
else
echo "invalid choice"
fi;;
2) sudo echo "Robot 2 ..."
if [[ "$1" == "G" || "$2" == "G" || "$3" == "G" || "$1" == "g" || "$2" == "g" || "$3" == "g" ]]; then
CONF="y"
else
if [[ "$1" == "F" || "$2" == "F" || "$3" == "F" || "$1" == "f" || "$2" == "f" || "$3" == "f" ]]; then
CONF="n"
else
sudo echo "Artificial Grass [Y/N]: "
read CONF
fi
fi
if [ "$CONF" = "y" ]
then
ln -sf ../../conf_robos/02/grama/* .
ln -sf ../../conf_robos/02/vision/* ../../Vision/Data
echo "grass files copied!"
elif [ "$CONF" = "n" ]
then
ln -sf ../../conf_robos/02/chao/* .
ln -sf ../../conf_robos/02/vision/* ../../Vision/Data
echo "flat floor files copied!"
else
echo "invalid choice"
fi;;
3) sudo echo "Robot 3 ..."
if [[ "$1" == "G" || "$2" == "G" || "$3" == "G" || "$1" == "g" || "$2" == "g" || "$3" == "g" ]]; then
CONF="y"
else
if [[ "$1" == "F" || "$2" == "F" || "$3" == "F" || "$1" == "f" || "$2" == "f" || "$3" == "f" ]]; then
CONF="n"
else
sudo echo "Artificial Grass [Y/N]: "
read CONF
fi
fi
if [ "$CONF" = "y" ]
then
ln -sf ../../conf_robos/03/grama/* .
ln -sf ../../conf_robos/03/vision/* ../../Vision/Data
echo "grass files copied!"
elif [ "$CONF" = "n" ]
then
ln -sf ../../conf_robos/03/chao/* .
ln -sf ../../conf_robos/03/vision/* ../../Vision/Data
echo "flat floor files copied!"
else
echo "invalid choice"
fi;;
4) sudo echo "Robot 4 ..."
if [[ "$1" == "G" || "$2" == "G" || "$3" == "G" || "$1" == "g" || "$2" == "g" || "$3" == "g" ]]; then
CONF="y"
else
if [[ "$1" == "F" || "$2" == "F" || "$3" == "F" || "$1" == "f" || "$2" == "f" || "$3" == "f" ]]; then
CONF="n"
else
sudo echo "Artificial Grass [Y/N]: "
read CONF
fi
fi
if [ "$CONF" = "y" ]
then
ln -sf ../../conf_robos/04/grama/* .
ln -sf ../../conf_robos/04/vision/* ../../Vision/Data
echo "grass files copied!"
elif [ "$CONF" = "n" ]
then
ln -sf ../../conf_robos/04/chao/* .
ln -sf ../../conf_robos/04/vision/* ../../Vision/Data
echo "flat floor files copied!"
else
echo "invalid choice"
fi;;
*) sudo echo "Invalid robot number!" ;;
esac
fi
cd ../../..
echo -e "${blue} That's all folks! Have fun! ${NC}"