-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-rpi.sh
executable file
·372 lines (335 loc) · 14.4 KB
/
install-rpi.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
#!/bin/bash
#####################
# Author: Alexandre Amory
# Date: September/2016, December/2016
# Laboratorio de Sistemas Autonomos - FACIN - PUCRS University
# Description:
# This script installs all the required depedencies (packages) in the RPi.
# No compilation is performed on RPi.
# Run this before cross compilation (install-cross-pi.sh) !
# How to Execute:
#
# Note that this script is meant for Donnie`s developers, not for users,
# since one will execute this script only if the software running on RPi is changed.
# Normal users will burn a pre-build RPi image for their Donnie robot.
#
# copy this script to the RPi
# $ scp install-rpi.sh pi@<rpi-ip>:~
# log on RPi and run the script
# $ ssh pi@<rpi-ip>
# $ sudo ./install-rpi.sh
# TODO: tenho duvidas se preciso instalar *-dev ou se seria necessario somente as libs sem headers.
# se *-dev for necessario para cross compiling, entao eu acho q eles nao seriam necessarios na
# distribuicao final. depois de cross compilado, seria possivel remover *-dev, e somente instalar
# as libs
# Any subsequent(*) commands which fail will cause the shell script to exit immediately
set -e
#defensive script
#http://www.davidpashley.com/articles/writing-robust-shell-scripts/#id2382181
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${RED}Running Donnie Compilation Script for Raspberry Pi ... ${NC}\n"
if [ -z "$DONNIE_PATH" ]; then
echo -e "${RED}ERROR:${NC} Need to set DONNIE_PATH environment variable\n"
echo -e "Example: export DONNIE_PATH=/opt/donnie\n"
exit 1
fi
echo -e "DONNIE_PATH=${DONNIE_PATH}\n"
export DONNIE_SOURCE_PATH=${PWD}/donnie-assistive-robot-sw
echo -e "DONNIE_SOURCE_PATH=${DONNIE_SOURCE_PATH}\n"
##################################################
# check the supported OS version and distribution
##################################################
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
OSNAME=$(lsb_release -sc)
case ${OS} in
Raspbian)
echo -e "${ORANGE}WARNING:${NC} Raspbian is recommended only for Raspberry Pi\n"
case ${VER} in
8.0)
echo -e "${GREEN}NOTE:${NC} ${OS} - ${VER} (${OSNAME}) is the recommended OS version.\n"
;;
*)
# Handle other OS versions here
echo -e "${ORANGE}WARNING:${NC} ${OS} - ${VER} (${OSNAME}) is not a recommended OS version. You might get errors and some programming experience is required to compile Donnie. \n"
echo -e "${GREEN}NOTE:${NC} Raspbian Version 8 (Jessie) is the recommended version for ${OS}\n"
exit 1;
;;
esac
;;
*)
# Handle other distributions here
echo -e "${RED}ERROR:${NC} ${OS} is not a supported OS\n"
echo -e "${GREEN}NOTE:${NC} Raspbian Version 8 (Jessie) is recommended for Donnie's computer (Raspberry Pi)\n"
exit 1;
;;
esac
NUM_CORES=`cat /proc/cpuinfo | grep processor | wc -l`
echo -e "${GREEN}NOTE:${NC} This computer has ${NUM_CORES} cores ...\n"
##################################################
# Setting up Raspberry Pi
##################################################
echo -e "${GREEN}Setting up Raspberry Pi ... ${NC}\n"
#Desativa o login serial da Raspberry (Para evitar o conflito da serial do Arduino)
#Source: http://spellfoundry.com/sleepypi/settingarduinoideraspbian/
sudo systemctl mask [email protected]
#Configurando o desligamento da raspberry (Shutdown) por interrupção do pino GPIO4
#Referencia(No link tem outros uso para a GPIO Zero também): http://bennuttall.com/gpio-zero-developing-a-new-friendly-python-api-for-physical-computing/
sudo apt-get install python3-gpiozero python-gpiozero
# '$' means the last line, 'i' means insert before the current line, so '$i' means insert before the last line.
sudo sed -i -e '$i \sleep 10\n' /etc/rc.local ## this sleep is required to play festival. sometimes rc.locals plays too early
sudo sed -i -e '$i \nohup sudo python '"${DONNIE_PATH}"'/scripts/softshutdown.py &\n' /etc/rc.local
# script used to Donnie tell its IP address at startup
sudo apt-get install -y festival
sudo sed -i -e '$i \nohup sudo python '"${DONNIE_PATH}"'/scripts/speechIP.py &\n' /etc/rc.local
echo -e "${GREEN}Raspberry Pi Set Up Completed !!!!${NC}\n"
##################################################
# install commom packages
##################################################
sudo apt-get update
# nice to have, not mandatory
sudo apt-get install -y geany
#compilation utils
echo -e "${GREEN}Installing Compilation Utils ... ${NC}\n"
sudo apt-get install -y build-essential autoconf git pkg-config
# Jessie installs cmake 3.0 by the default, but lubuntu 14.04 uses cmake 2.8
# this gives some weird warnings when running cmake 3.0 on rpi.
# so we downgraded the cmake to 2.8, used in wheezy
# https://www.raspbian.org/RaspbianRepository
wget https://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add -
echo "deb http://archive.raspbian.org/raspbian wheezy main contrib non-free" | sudo tee --append /etc/apt/sources.list > /dev/null
echo "deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free" | sudo tee --append /etc/apt/sources.list > /dev/null
sudo apt-get update
#apt-cache madison cmake
sudo apt-get install -y cmake-data=2.8.9-1
sudo apt-get install -y cmake=2.8.9-1
sudo apt-get install -y cmake-curses-gui=2.8.9-1
##################################################
# install Player depedencies
##################################################
# TODO remove the Stage related packages
echo -e "${GREEN}Installing Player Dependencies ... ${NC}\n"
#sudo apt-get install -y libfltk1.1-dev
#sudo apt-get install -y freeglut3-dev # <= talvez nao precise no player se desabilitar pmap
sudo apt-get install -y libpng12-dev
#sudo apt-get install -y libltdl-dev
#sudo apt-get install -y libdb5.1-stl
sudo apt-get install -y libgnomecanvasmm-2.6-dev
#sudo apt-get install -y python-gnome2
sudo apt-get install -y libboost-all-dev # overkill, the actually required libraries are boostthread, boostsignal, boostsystem
#sudo apt-get install -y libboost-dev
# old OpenCV for older Player drivers
# sudo apt-get install -y libopencv-dev # <= install all packages ... not required
# sudo apt-get install -y libopencv-dev libopencv-core-dev libcv-dev libcvaux-dev libhighgui-dev
sudo apt-get install -y libopencv-core-dev libhighgui-dev libcv-dev libopencv-dev
# alsa - sound player
# http://player-stage-gazebo.10965.n7.nabble.com/CCmake-cannot-find-the-existing-asoundlib-h-for-ALSA-driver-td11198.html
sudo apt-get install -y libasound2-dev
# alsa alsa-tools alsa-utils
# for pmap
#sudo apt-get install -y libgsl0-dev libxmu-dev
# for python bindings for Player clients -
# It is not recommended to use python due to limitations in the bindings.
# Things that work on a C/C++ client might not work on a Python client.
#sudo apt-get install -y python-dev swig
# PostGIS for a Player driver
sudo apt-get install -y libpq-dev libpqxx-dev
##################################################
# install Donnie depedencies
##################################################
# Donnie's depedencies
echo -e "${GREEN}Installing Donnie Dependencies on RPi ... ${NC}\n"
#to compile soxplayer driver
#sudo apt-get install -y sox
sudo apt-get install -y libsox-dev
#to compile gtts driver
#sudo apt-get install -y curl
sudo apt-get install -y libcurl4-openssl-dev
#Instalar o TIMIDITY para poder usar os canais virtuais de MIDI (Virtual MIDI Port) e usar notas musicais no autofalante
sudo apt-get install -y timidity
# std terminal used in several linux distributions
apt-get install xterm
#Testando saida do auto falante
#$speaker-test -t sine -f 1000 -c 2
#Selecionar a saida para o jack p2
#sudo amixer cset numid=3 1 # headphones
#sudo amixer cset numid=3 0 # Auto
#sudo amixer cset numid=3 2 # HDMI
#Controle do volume
#sudo alsamixer
#Tocando um mp3
#omxplayer mp3name.mp3
##################################################
# Donwloading source code
##################################################
echo -e "${GREEN}Downloading Player source code from GitHub... ${NC}\n"
git clone https://github.com/lsa-pucrs/Player.git
echo -e "${GREEN}Downloading Raspicam source code from GitHub... ${NC}\n"
git clone https://github.com/lsa-pucrs/raspicam.git
echo -e "${GREEN}Downloading Donnie source code from GitHub... ${NC}\n"
git clone -b devel https://github.com/lsa-pucrs/donnie-assistive-robot-sw.git
##################################################
# Compile and install Player
##################################################
cd Player
patch -p1 -N --dry-run --silent < patch/festival/festival.patch 2>/dev/null
#If the patch has not been applied then the $? which is the exit status
#for last command would have a success status code = 0
if [ $? -eq 0 ];
then
#apply the patch
echo -e "${GREEN}Patching Player ... ${NC}\n"
patch -p1 < patch/festival/festival.patch
patch -p1 < patch/install/player_3.0.2_14.04.patch
patch -p1 < ../donnie-assistive-robot-sw/proxies/instalationSoundProxy.patch
echo -e "${GREEN}Patching Player for Donnie ... ${NC}\n"
fi
mkdir -p build # mkdir -p is safer !
cd build
echo -e "${GREEN}Configuring Player ... ${NC}\n"
#disablingCMAKE_INSTALL_PREFIX all the unused drivers and utils...
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DDEBUG_LEVEL=NONE \
-DBUILD_PYTHONC_BINDINGS:BOOL=OFF \
-DBUILD_EXAMPLES:BOOL=OFF \
-DBUILD_UTILS_XMMS:BOOL=OFF \
-DBUILD_UTILS_PMAP:BOOL=OFF \
-DBUILD_UTILS_PLAYERNAV:BOOL=OFF \
-DBUILD_UTILS_PLAYERPRINT:BOOL=OFF \
-DBUILD_UTILS_PLAYERPROP:BOOL=OFF \
-DBUILD_UTILS_PLAYERV:BOOL=OFF \
-DBUILD_UTILS_PLAYERVCR:BOOL=OFF \
-DBUILD_UTILS_PLAYERWRITEMAP:BOOL=OFF \
-DBUILD_UTILS_LOGSPLITTER:BOOL=OFF \
-DENABLE_DRIVER_ACCEL_CALIB:BOOL=OFF \
-DENABLE_DRIVER_ACTS:BOOL=OFF \
-DENABLE_DRIVER_AIOTOSONAR:BOOL=OFF \
-DENABLE_DRIVER_AMTECPOWERCUBE:BOOL=OFF \
-DENABLE_DRIVER_AODV:BOOL=OFF \
-DENABLE_DRIVER_BITLOGIC:BOOL=OFF \
-DENABLE_DRIVER_CAMERA1394:BOOL=OFF \
-DENABLE_DRIVER_CANONVCC4:BOOL=OFF \
-DENABLE_DRIVER_CLODBUSTER:BOOL=OFF \
-DENABLE_DRIVER_CMDSPLITTER:BOOL=OFF \
-DENABLE_DRIVER_CMUCAM2:BOOL=OFF \
-DENABLE_DRIVER_CMVISION:BOOL=OFF \
-DENABLE_DRIVER_CREATE:BOOL=OFF \
-DENABLE_DRIVER_DEADSTOP:BOOL=OFF \
-DENABLE_DRIVER_EPUCK:BOOL=OFF \
-DENABLE_DRIVER_ER1:BOOL=OFF \
-DENABLE_DRIVER_ERRATIC:BOOL=OFF \
-DENABLE_DRIVER_FLOCKOFBIRDS:BOOL=OFF \
-DENABLE_DRIVER_GARMINNMEA:BOOL=OFF \
-DENABLE_DRIVER_IMAGESEQ:BOOL=OFF \
-DENABLE_DRIVER_IMGCMP:BOOL=OFF \
-DENABLE_DRIVER_INHIBITOR:BOOL=OFF \
-DENABLE_DRIVER_INSIDEM300:BOOL=OFF \
-DENABLE_DRIVER_IWSPY:BOOL=OFF \
-DENABLE_DRIVER_KARTOWRITER:BOOL=OFF \
-DENABLE_DRIVER_KHEPERA:BOOL=OFF \
-DENABLE_DRIVER_LASERBAR:BOOL=OFF \
-DENABLE_DRIVER_LASERBARCODE:BOOL=OFF \
-DENABLE_DRIVER_LASERCSPACE:BOOL=OFF \
-DENABLE_DRIVER_LASERCUTTER:BOOL=OFF \
-DENABLE_DRIVER_LASERPOSEINTERPO:BOOL=OFF \
-DENABLE_DRIVER_LASERPTZCLOUD:BOOL=OFF \
-DENABLE_DRIVER_LASERRESCAN:BOOL=OFF \
-DENABLE_DRIVER_LASERSAFE:BOOL=OFF \
-DENABLE_DRIVER_LOCALBB:BOOL=OFF \
-DENABLE_DRIVER_MBICP:BOOL=OFF \
-DENABLE_DRIVER_MICA2:BOOL=OFF \
-DENABLE_DRIVER_MICROSTRAIN:BOOL=OFF \
-DENABLE_DRIVER_MOTIONMIND:BOOL=OFF \
-DENABLE_DRIVER_MRICP:BOOL=OFF \
-DENABLE_DRIVER_NOMAD:BOOL=OFF \
-DENABLE_DRIVER_OBOT:BOOL=OFF \
-DENABLE_DRIVER_OCEANSERVER:BOOL=OFF \
-DENABLE_DRIVER_P2OS:BOOL=OFF \
-DENABLE_DRIVER_PASSTHROUGH:BOOL=OFF \
-DENABLE_DRIVER_PBSLASER:BOOL=OFF \
-DENABLE_DRIVER_POSTGIS:BOOL=OFF \
-DENABLE_DRIVER_POSTLOG:BOOL=OFF \
-DENABLE_DRIVER_PTU46:BOOL=OFF \
-DENABLE_DRIVER_RELAY:BOOL=OFF \
-DENABLE_DRIVER_RFLEX:BOOL=OFF \
-DENABLE_DRIVER_ROBOTEQ:BOOL=OFF \
-DENABLE_DRIVER_ROBOTRACKER:BOOL=OFF \
-DENABLE_DRIVER_ROOMBA:BOOL=OFF \
-DENABLE_DRIVER_RS4LEUZE:BOOL=OFF \
-DENABLE_DRIVER_RT3XXX:BOOL=OFF \
-DENABLE_DRIVER_SEARCHPATTERN:BOOL=OFF \
-DENABLE_DRIVER_SEGWAYRMP400:BOOL=OFF \
-DENABLE_DRIVER_SERIALSTREAM:BOOL=OFF \
-DENABLE_DRIVER_SERIO:BOOL=OFF \
-DENABLE_DRIVER_SICKLDMRS:BOOL=OFF \
-DENABLE_DRIVER_SICKLMS200:BOOL=OFF \
-DENABLE_DRIVER_SICKLMS400:BOOL=OFF \
-DENABLE_DRIVER_SICKNAV200:BOOL=OFF \
-DENABLE_DRIVER_SICKRFI341:BOOL=OFF \
-DENABLE_DRIVER_SICKS3000:BOOL=OFF \
-DENABLE_DRIVER_SKYETEKM1:BOOL=OFF \
-DENABLE_DRIVER_SONYEVID30:BOOL=OFF \
-DENABLE_DRIVER_SPHEREPTZ:BOOL=OFF \
-DENABLE_DRIVER_SUPPRESSOR:BOOL=OFF \
-DENABLE_DRIVER_UPCBARCODE:BOOL=OFF \
-DENABLE_DRIVER_WBR914:BOOL=OFF \
-DPLAYER_BUILD_TESTS:BOOL=OFF \
-DBUILD_CC_TESTS:BOOL=OFF \
..
echo -e "${GREEN}Compiling Player ... ${NC}\n"
make -j ${NUM_CORES}
sudo make install
echo -e "${GREEN}Player installed !!!! ${NC}\n"
##################################################
# Compiling raspicam driver
##################################################
#https://solderspot.wordpress.com/2016/02/04/cross-compiling-for-raspberry-pi-part-ii/
cd ../../raspicam
mkdir -p build
cd build
echo -e "${GREEN}Configuring raspicam ... ${NC}\n"
cmake -DCMAKE_BUILD_TYPE=Release \
..
echo -e "${GREEN}Compiling raspicam ... ${NC}\n"
make -j ${NUM_CORES}
sudo make install
echo -e "${GREEN}Raspicam installed !!!! ${NC}\n"
#run the follwing command to test raspicam
#raspivid -o - -t 9999999 -w 1280 -h 1024 -b 500000 -fps 20 -vf
#Testing Raspicam via ssh
#https://www.raspberrypi.org/forums/viewtopic.php?t=67571
#http://raspi.tv/2013/how-to-stream-video-from-your-raspicam-to-your-nexus-7-tablet-using-vlc
#1) Precisa do vlc (para o comando cvlc)
sudo apt-get install -y vlc
#2) Executar processo da camera
#raspivid -o - -t 99999 -w 640 -h 360 -fps 5 -vf|cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264
#Obs: Para conectar entrar no endereço (pelo streaming do VLC no PC) http://192.168.0.XX:8090
##################################################
# Compiling and installing Donnie
##################################################
cd "${DONNIE_SOURCE_PATH}"
mkdir -p build
cd build
echo -e "${GREEN}Configuring Donnie ... ${NC}\n"
# CMAKE_SYSTEM_PROCESSOR=arm is required to avoid compiling things not used by the robot computer
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_PROCESSOR=arm ..
echo -e "${GREEN}Compiling Donnie ... ${NC}\n"
make -j ${NUM_CORES}
sudo make install
echo -e "${GREEN}Donnie installed !!!! ${NC}\n"
##################################################
# set environment variables for terminals
##################################################
echo "source $DONNIE_PATH/setup.sh" >> ~/.bashrc
##################################################
# uninstall all dev packages to save space
##################################################
echo -e "${GREEN}Cleaning the cache ... ${NC}\n"
sudo apt-get -y autoclean
sudo apt-get -y autoremove
echo -e "${GREEN}End of installation !!!! ${NC}\n"