Commit 84a1138b authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

wip

parent 0b772d8f
Pipeline #8674 failed with stages
in 13 minutes and 45 seconds
#!/bin/bash
set -e
# COLORS
BLACK='\033[0;30m'
DARK_GRAY='\033[1;30m'
RED='\033[0;31m'
LIGHT_RED='\033[1;31m'
GREEN='\033[0;32m'
LIGHT_GREEN='\033[1;32m'
ORANGE='\033[0;33m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
LIGHT_BLUE='\033[1;34m'
PURPLE='\033[0;35m'
LIGHT_PURPLE='\033[1;35m'
CYAN='\033[0;36m'
LIGHT_CYAN='\033[1;36m'
LIGHT_GRAY='\033[0;37m'
WHITE='\033[1;37m'
BOLD='\033[1m'
RESET_STYLE='\033[0m'
## FUNCTIONS #####################################################
func_make_install () {
if [ "$UID" -eq 0 -o "$EUID" -eq 0 ]; then
......@@ -19,37 +39,39 @@ func_ldconfig () {
}
func_echo () {
if [ $VERBOSE == "true" ]; then
echo "$1"
fi
echo -e "\n${BOLD}[install_wolf]: ${BLUE}${1}${RESET_STYLE}"
}
func_echo_error () {
echo -e "\n${BOLD}[install_wolf]: ${RED}${1}${RESET_STYLE}"
}
usage() {
echo "Usage: $0 [-v] [-a] [-d <string>] [-w <string>] [-p <string>] [-f <y/n>] [-c <y/n>]"
echo " v: disables echo"
echo " a: installs all plugins (incompatible with -p)"
echo " d: dependencies destination path (either /global/path or relative/path). If not set, will be asked later."
echo " w: wolf folder destination path (either /global/path or relative/path). If not set, will be asked later."
echo " p: plugins to be installed (incompatible with -a) being a string of 6 chars y/n corresponding to plugins imu, gnss, laser, vision, apriltag, bodydynamics (for example 'ynynnn'). Plugins apriltag and bodydynamics won't be installed if vision and imu plugins are installed, respectively."
echo " f: y/n install Falko optional dependency. If not set, will be asked later."
echo " c: y/n install CSM optional dependency. If not set, will be asked later."
echo -e "\n${BOLD}[install_wolf]: ${BLUE}Usage: $0 with the following optional inputs. If not set, everything will be asked during execution."
echo -e " ${BOLD}-d <string>${BLUE}: dependencies destination path (either /global/path or relative/path)."
echo -e " ${BOLD}-w <string>${BLUE}: wolf folder destination path (either /global/path or relative/path)."
echo -e " ${BOLD}-a ${BLUE}: installs all plugins (incompatible with -p)"
echo -e " ${BOLD}-p <string>${BLUE}: plugins to be installed (incompatible with -a) being a string of 6 chars y/n corresponding to plugins imu, gnss, laser, vision, apriltag, bodydynamics (for example 'ynynnn'). Plugins apriltag and bodydynamics won't be installed if vision and imu plugins are installed, respectively."
echo -e " ${BOLD}-f <y/n>${BLUE}: install Falko optional laser dependency (if laser plugin is installed)."
echo -e " ${BOLD}-c <y/n>${BLUE}: install CSM optional laser dependency (if laser plugin is installed).${RESET_STYLE}"
}
func_check_yn () {
if [ "$1" != "y" ] && [ "$1" != "n" ]; then
echo "options -p, -f, -c should containing only 'y' or 'n'"
func_echo_error "options -p, -f, -c should containing only 'y' or 'n'"
usage
exit 0
fi
}
# START #####################################################
CORES=$(nproc)
func_echo "The number of available cores on this machine is $CORES"
RUN_PATH=$PWD
## OPTIONS #####################################################
VERBOSE="true"
INSTALL_PLUGINS=""
INSTALL_IMU="undefined"
INSTALL_GNSS="undefined"
......@@ -62,17 +84,14 @@ INSTALL_CSM="undefined"
DEPS_PATH="undefined"
WOLF_PATH="undefined"
while getopts "vap:d:w:hf:c:" opt; do
while getopts "ap:d:w:hf:c:" opt; do
case ${opt} in
v) # disable verbose
VERBOSE="false"
;;
a) # install all plugins
if [ "$INSTALL_PLUGINS" != "" ]; then
echo "options -p and -a are incompatible!"
usage
exit 0
fi
if [ "$INSTALL_PLUGINS" != "" ]; then
func_echo_error "options -p and -a are incompatible."
usage
exit 0
fi
INSTALL_PLUGINS="a"
INSTALL_IMU="y"
INSTALL_GNSS="y"
......@@ -82,15 +101,15 @@ while getopts "vap:d:w:hf:c:" opt; do
INSTALL_BODYDYNAMICS="y"
;;
p) # install all plugins
if [ "$INSTALL_PLUGINS" != "" ]; then
echo "options -p and -a are incompatible!"
usage
exit 0
fi
if [ "$INSTALL_PLUGINS" != "" ]; then
func_echo_error "options -p and -a are incompatible."
usage
exit 0
fi
if [ ${#OPTARG} != 6 ]; then
echo "option -p should contain 6 characters"
usage
exit 0
func_echo_error "option -p should contain 6 characters."
usage
exit 0
fi
INSTALL_PLUGINS=$OPTARG
INSTALL_IMU=${INSTALL_PLUGINS:0:1}
......@@ -119,7 +138,7 @@ while getopts "vap:d:w:hf:c:" opt; do
if cd $DEPS_PATH ; then
func_echo "Valid dependency path."
else
echo "Invalid dependency path."
func_echo_error "Invalid dependency path."
exit 1
fi
;;
......@@ -128,16 +147,16 @@ while getopts "vap:d:w:hf:c:" opt; do
if cd $WOLF_PATH ; then
func_echo "Valid wolf folder path."
else
echo "Invalid wolf folder path."
func_echo_error "Invalid wolf folder path."
exit 1
fi
;;
h )
h ) # help
usage
exit 0
;;
:)
echo "Error: -${OPTARG} requires an argument."
func_echo_error "Error: -${OPTARG} requires an argument."
usage
exit 1
;;
......@@ -163,7 +182,7 @@ if [ $UBUNTU_DISTRO == "18.04" ]; then
elif [ $UBUNTU_DISTRO == "20.04" ]; then
func_echo "Ubuntu 20.04 - OK"
else
echo "Non-supported Ubuntu version: $UBUNTU_DISTRO"
func_echo_error "Non-supported Ubuntu version: ${UBUNTU_DISTRO}"
exit 1
fi
......@@ -172,11 +191,12 @@ fi
cd $RUN_PATH
func_echo "You are in folder $PWD"
if [ $DEPS_PATH == "undefined" ]; then
echo "Enter path for dependencies (either /global/path or relative/path):"
func_echo "Enter path for dependencies (either /global/path or relative/path):"
read DEPS_PATH
fi
while ! cd $DEPS_PATH ; do
echo "Invalid dependency path. Enter path for dependencies (either /global/path or relative/path):"
func_echo_error "Invalid dependency path."
func_echo "Enter path for dependencies (either /global/path or relative/path):"
read DEPS_PATH
done
DEPS_PATH=$PWD
......@@ -218,13 +238,14 @@ func_make_install
cd $RUN_PATH
func_echo "You are in folder $PWD"
if [ $WOLF_PATH == "undefined" ]; then
echo "Enter path for wolf folder (either /global/path or relative/path):"
func_echo "Enter path for wolf folder (either /global/path or relative/path):"
read WOLF_PATH
while ! cd $WOLF_PATH ; do
func_echo_error "Invalid dependency path."
func_echo "Enter path for dependencies (either /global/path or relative/path):"
read WOLF_PATH
done
fi
while ! cd $WOLF_PATH ; do
echo "Invalid dependency path. Enter path for dependencies (either /global/path or relative/path):"
read WOLF_PATH
done
mkdir wolf
cd wolf
WOLF_PATH=$PWD
......@@ -251,8 +272,13 @@ ctest -j$CORES
# IMU --------------------------------------------------
if [ $INSTALL_IMU == "undefined" ]; then
echo "Do you want to download and install plugin imu? (y/n)"
func_echo "Do you want to download and install plugin imu? (y/n)"
read INSTALL_IMU
while [ $INSTALL_IMU != "y" ] && [ $INSTALL_IMU != "n" ]; do
func_echo_error "wrong input ${INSTALL_IMU}"
func_echo "Do you want to download and install plugin imu? (y/n)"
read INSTALL_IMU
done
fi
if [ $INSTALL_IMU == "y" ]; then
......@@ -277,8 +303,13 @@ fi
# GNSS --------------------------------------------------
if [ $INSTALL_GNSS == "undefined" ]; then
echo "Do you want to download and install plugin gnss? (y/n)"
func_echo "Do you want to download and install plugin gnss? (y/n)"
read INSTALL_GNSS
while [ $INSTALL_GNSS != "y" ] && [ $INSTALL_GNSS != "n" ]; do
func_echo_error "wrong input ${INSTALL_GNSS}"
func_echo "Do you want to download and install plugin gnss? (y/n)"
read INSTALL_GNSS
done
fi
if [ $INSTALL_GNSS == "y" ]; then
......@@ -315,8 +346,13 @@ fi
# LASER --------------------------------------------------
if [ $INSTALL_LASER == "undefined" ]; then
echo "Do you want to download and install plugin laser? (y/n)"
func_echo "Do you want to download and install plugin laser? (y/n)"
read INSTALL_LASER
while [ $INSTALL_LASER != "y" ] && [ $INSTALL_LASER != "n" ]; do
func_echo_error "wrong input ${INSTALL_LASER}"
func_echo "Do you want to download and install plugin laser? (y/n)"
read INSTALL_LASER
done
fi
if [ $INSTALL_LASER == "y" ]; then
......@@ -324,8 +360,13 @@ if [ $INSTALL_LASER == "y" ]; then
# CSM
if [ $INSTALL_CSM == "undefined" ]; then
echo "Do you want to install CSM to enable ICP processors? (y/n)"
func_echo "Do you want to install CSM to enable ICP processors? (y/n)"
read INSTALL_CSM
while [ $INSTALL_CSM != "y" ] && [ $INSTALL_CSM != "n" ]; do
func_echo_error "wrong input ${INSTALL_CSM}"
func_echo "Do you want to install CSM to enable ICP processors? (y/n)"
read INSTALL_CSM
done
fi
if [ $INSTALL_CSM == "y" ]; then
if [ "$UID" -eq 0 -o "$EUID" -eq 0 ]; then
......@@ -346,8 +387,13 @@ if [ $INSTALL_LASER == "y" ]; then
# FALKO
if [ $INSTALL_FALKO == "undefined" ]; then
echo "Do you want to install FALKO to enable Falko loop closure processors? (y/n)"
func_echo "Do you want to install FALKO to enable Falko loop closure processors? (y/n)"
read INSTALL_FALKO
while [ $INSTALL_FALKO != "y" ] && [ $INSTALL_FALKO != "n" ]; do
func_echo_error "wrong input ${INSTALL_FALKO}"
func_echo "Do you want to install CSM to enable Falko loop closure processors? (y/n)"
read INSTALL_FALKO
done
fi
if [ $INSTALL_FALKO == "y" ]; then
cd $DEPS_PATH
......@@ -397,8 +443,13 @@ fi
# VISION --------------------------------------------------
if [ $INSTALL_VISION == "undefined" ]; then
echo "Do you want to download and install plugin vision (requires to install opencv 3.3.0)? (y/n)"
func_echo "Do you want to download and install plugin vision (requires to install opencv 3.3.0)? (y/n)"
read INSTALL_VISION
while [ $INSTALL_VISION != "y" ] && [ $INSTALL_VISION != "n" ]; do
func_echo_error "wrong input ${INSTALL_VISION}"
func_echo "Do you want to download and install plugin vision (requires to install opencv 3.3.0)? (y/n)"
read INSTALL_VISION
done
fi
if [ $INSTALL_VISION == "y" ]; then
......@@ -414,7 +465,7 @@ if [ $INSTALL_VISION == "y" ]; then
mkdir build
cd build
sed -i 's/char\* str = PyString_AsString(obj)/const char\* str = PyString_AsString(obj)/g' ../modules/python/src2/cv2.cpp
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_CXX_FLAGS="-fPIC -std=c++14" -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_CXX_FLAGS="-fPIC -std=c++14" -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules -D WITH_FFMPEG=OFF ..
make -j$CORES
func_make_install
......@@ -449,8 +500,13 @@ fi
# APRILTAG --------------------------------------------------
if [ $INSTALL_VISION == "y" ]; then
if [ $INSTALL_APRILTAG == "undefined" ]; then
echo "Do you want to download and install plugin apriltag? (y/n)"
func_echo "Do you want to download and install plugin apriltag? (y/n)"
read INSTALL_APRILTAG
while [ $INSTALL_APRILTAG != "y" ] && [ $INSTALL_APRILTAG != "n" ]; do
func_echo_error "wrong input ${INSTALL_APRILTAG}"
func_echo "Do you want to download and install plugin apriltag? (y/n)"
read INSTALL_APRILTAG
done
fi
if [ $INSTALL_APRILTAG == "y" ]; then
......@@ -489,8 +545,13 @@ fi
# BODYDYNAMICS --------------------------------------------------
if [ $INSTALL_IMU == "y" ]; then
if [ $INSTALL_BODYDYNAMICS == "undefined" ]; then
echo "Do you want to download and install plugin bodydynamics? (y/n)"
func_echo "Do you want to download and install plugin bodydynamics? (y/n)"
read INSTALL_BODYDYNAMICS
while [ $INSTALL_BODYDYNAMICS != "y" ] && [ $INSTALL_BODYDYNAMICS != "n" ]; do
func_echo_error "wrong input ${INSTALL_BODYDYNAMICS}"
func_echo "Do you want to download and install plugin bodydynamics? (y/n)"
read INSTALL_BODYDYNAMICS
done
fi
if [ $INSTALL_BODYDYNAMICS == "y" ]; then
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment