-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-ros-ubuntu-x86.sh
executable file
·120 lines (103 loc) · 3.64 KB
/
install-ros-ubuntu-x86.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
#!/bin/bash
#
# Author: Spyridakis Christos
# Creation Date: 11/8/2021
# Last update: 5/9/2021
#
# Description:
# Install ROS (Robot Operating System) melodic or noetic version - on Ubuntu OS
#
# Instructions based on official Documentation
# https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
#
#
# Extra:
LOG_FILENAME="${HOME}/install-ros-ubuntu-x86-log.txt"
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
reset=`tput sgr0`
procNumber=$(nproc --all)
echoe(){
echo "${red}[ERRO]${reset} $@" | tee -a "${LOG_FILENAME}"
}
echoi(){
echo "${yellow}[INFO]${reset} $@" | tee -a "${LOG_FILENAME}"
}
ROS_DISTRO=""
INST_TYPE=""
helpMenu(){
echo "Usage: $0 [Option] [Option]"
echo "Install ROS (Robot Operating System) melodic or noetic version - on Ubuntu OS"
echo
echo "Options:"
echo " -b, --base install base version of ROS"
echo " -d, --desktop install desktop version of ROS"
echo " -f, --full install desktop-full version of ROS"
echo " -h, --help print this help menu and exit"
echo " -m, --melodic install melodic distro of ROS"
echo " -n, --noetic install noetic distro of ROS"
}
installation(){
# Setup your sources.list
echoi "Setup your sources.list"
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
# Set up your keys
echoi "Set up your keys"
sudo apt -y install curl # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
# Installation
sudo apt -y update
if [ "${INST_TYPE}" == "full" ] ; then
echoi "Full Installation"
sudo apt -y install ros-${ROS_DISTRO}-desktop-full # Desktop-Full Install
elif [ "${INST_TYPE}" == "desktop" ] ; then
echoi "Desktop Installation"
sudo apt -y install ros-${ROS_DISTRO}-desktop # Desktop Install
elif [ "${INST_TYPE}" == "base" ] ; then
echoi "Base Installation"
sudo apt -y install ros-${ROS_DISTRO}-ros-base # ROS-Base
fi
# Environment setup
echoi "Environment setup"
echo -e "\nsource /opt/ros/${ROS_DISTRO}/setup.bash \n" >> ~/.bashrc
[ ${SHELL} = "/usr/bin/zsh" ] && (echo -e "\nsource /opt/ros/${ROS_DISTRO}/setup.zsh \n" >> ~/.zshrc && source ~/.zshrc)
# Dependencies for building packages
echoi "Install dependencies for building packages"
sudo apt -y install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
# Initialize rosdep
echoi "Initialize rosdep"
sudo apt -y install python3-rosdep
sudo rosdep init
rosdep update
echoi "Installation Completed Successfully!"
}
while :
do
case "$1" in
-b | --base) INST_TYPE="base" ; shift ;;
-d | --desktop) INST_TYPE="desktop" ; shift ;;
-f | --full) INST_TYPE="full" ; shift ;;
-h | --help) helpMenu ; exit 0 ;;
-m | --melodic) ROS_DISTRO="melodic" ; shift ;;
-n | --noetic) ROS_DISTRO="noetic" ; shift ;;
--*)
echoe "Unknown option: $1" >&2
helpMenu
exit 1
;;
-*)
echoe "Unknown option: $1" >&2
helpMenu
exit 1
;;
*)
break
esac
done
if [ ! -z ${INST_TYPE} ] && [ ! -z ${ROS_DISTRO} ] ; then
installation
else
echoe "Please give installation type and ros distro to install. "
echoe "Run ./`basename $0` -h for more"
fi