-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·197 lines (179 loc) · 4.5 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
blue='\e[0;34m'
NC='\e[0m' # No Color
red='\e[0;31m'
green='\e[0;32m'
echo
echo "This script will configure RoboFEI-HT software"
echo
read -p "Continue? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]
then
exit 1
fi
sudo echo "Will this setup be used for Simulation or Real robot (S/R)? "
read MODE
if [ $MODE == "S" ] || [ $MODE == "s" ];
then
echo -e "${blue} ***** SIMULATION MODE ***** ${NC}"
echo
read -p "How many robots do you want to compile? "
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
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"
EOF
chmod +x 41-ftdi-imu.rules
sudo echo -e "Copying file${blue} 41-ftdi-imu.rules${NC} to ${green}/etc/udev/rules.d${NC}"
sudo cp 41-ftdi-imu.rules /etc/udev/rules.d
sudo echo -e "Creating rules for recognizing devices${red} Servo${NC}"
cat <<EOF > 41-ftdi-servo.rules
KERNEL=="ttyUSB?", SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}!="A501VRKI", ATTRS{serial}!="A501VROG", ATTRS{serial}!="A501VM7A", ATTRS{product}=="FT232R USB UART", MODE="0777", SYMLINK+="robot/servo%n"
EOF
chmod +x 41-ftdi-servo.rules
sudo echo -e "Copying file${blue} 41-ftdi-servo.rules${NC} to ${green}/etc/udev/rules.d${NC}"
sudo cp 41-ftdi-servo.rules /etc/udev/rules.d
sudo echo "Restarting udev"
sudo service udev restart
cd ..
cd Control/Data/
pwd
sudo echo "Starting robots configuration"
sudo echo "Insert robot number: "
read NUM
case $NUM in
1) sudo echo "Robot 1 ..."
sudo echo "Artificial Grass [Y/N]: "
read CONF
if [ "$CONF" = "y" ]
then
ln -sf ../../conf_robos/01/grama/* .
echo "grass files copied!"
elif [ "$CONF" = "n" ]
then
ln -sf ../../conf_robos/01/chao/* .
echo "flat floor files copied!"
else
echo "invalid choice"
fi;;
2) sudo echo "Robot 2 ..."
sudo echo "Artificial Grass [Y/N]: "
read CONF
if [ "$CONF" = "y" ]
then
ln -sf ../../conf_robos/02/grama/* .
echo "grass files copied!"
elif [ "$CONF" = "n" ]
then
ln -sf ../../conf_robos/02/chao/* .
echo "flat floor files copied!"
else
echo "invalid choice"
fi;;
3) sudo echo "Robot 3 ..."
sudo echo "Artificial Grass [Y/N]: "
read CONF
if [ "$CONF" = "y" ]
then
ln -sf ../../conf_robos/03/grama/* .
echo "grass files copied!"
elif [ "$CONF" = "n" ]
then
ln -sf ../../conf_robos/03/chao/* .
echo "flat floor files copied!"
else
echo "invalid choice"
fi;;
4) sudo echo "Robot 4 ..."
sudo echo " Artificial Grass [Y/N]: "
read CONF
if [ "$CONF" = "y" ]
then
ln -sf ../../conf_robos/04/grama/* .
echo "grass files copied!"
elif [ "$CONF" = "n" ]
then
ln -sf ../../conf_robos/04/chao/* .
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}"