-
Notifications
You must be signed in to change notification settings - Fork 0
/
ros2_humble_install_on_20.04.sh
150 lines (121 loc) · 5.99 KB
/
ros2_humble_install_on_20.04.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
#! /bin/bash
# Install ROS2 Humble on 20.04 focal
# Copyright 2024 mkdir-sweetiepie
# https://github.com/mkdir-sweetiepie/ros_ubuntu_install
# Licensed under the MIT License
function custom_echo() {
text=$1 # 첫 번째 인자는 출력할 텍스트입니다.
color=$2 # 두 번째 인자는 출력할 색상입니다.
case $color in
"red")
echo -e "\033[31m[RO:BIT] $text\033[0m" # 빨간색으로 출력
;;
"green")
echo -e "\033[32m[RO:BIT] $text\033[0m" # 초록색으로 출력
;;
"yellow")
echo -e "\033[33m[RO:BIT] $text\033[0m" # 노란색으로 출력
;;
*)
echo "$text"
;;
esac
}
loading_animation() {
local interval=1 # 프레임 전환 간격을 설정 (0.1초 단위, 0.1초로 표시됨)
local duration=30 # 애니메이션 총 지속 시간 (초 단위)
local bar_length=$(tput cols) # 터미널 창의 너비를 가져옴
local total_frames=$((duration * interval)) # 총 프레임 수를 계산
local frame_chars=("█" "▉" "▊" "▋" "▌" "▍" "▎" "▏") # 로딩 애니메이션에 사용할 프레임 문자 배열
for ((i = 0; i <= total_frames; i++)); do
local frame_index=$((i % ${#frame_chars[@]})) # 현재 프레임 문자 인덱스를 계산
local progress=$((i * bar_length / total_frames)) # 진행 상황을 터미널 너비로 변환
local bar=""
for ((j = 0; j < bar_length; j++)); do
if ((j <= progress)); then
bar+="${frame_chars[frame_index]}" # 진행된 부분에 해당하는 프레임 문자 추가
else
bar+=" " # 진행되지 않은 부분에는 공백 추가
fi
done
printf "\r\033[32m%s\033[0m" "$bar" # 초록색으로 출력
sleep 0.$interval # 다음 프레임까지 대기 (여기서는 0.1초)
done
printf "\n"
}
text_art="
░█▀▀█ ░█▀▀▀█ ▄ ░█▀▀█ ▀█▀ ▀▀█▀▀ ░█▀▄▀█ ░█─▄▀ ░█▀▀▄ ▀█▀ ░█▀▀█
░█▄▄▀ ░█──░█ ─ ░█▀▀▄ ░█─ ─░█── ░█░█░█ ░█▀▄─ ░█─░█ ░█─ ░█▄▄▀
░█─░█ ░█▄▄▄█ ▀ ░█▄▄█ ▄█▄ ─░█── ░█──░█ ░█─░█ ░█▄▄▀ ▄█▄ ░█─░█
░█▀▀▀█ ░█──░█ ░█▀▀▀ ░█▀▀▀ ▀▀█▀▀ ▀█▀ ░█▀▀▀ ░█▀▀█ ▀█▀ ░█▀▀▀
─▀▀▀▄▄ ░█░█░█ ░█▀▀▀ ░█▀▀▀ ─░█── ░█─ ░█▀▀▀ ░█▄▄█ ░█─ ░█▀▀▀
░█▄▄▄█ ░█▄▀▄█ ░█▄▄▄ ░█▄▄▄ ─░█── ▄█▄ ░█▄▄▄ ░█─── ▄█▄ ░█▄▄▄
░█▀▀█ ░█▀▀▀█ ░█▀▀▀█
░█▄▄▀ ░█──░█ ─▀▀▀▄▄
░█─░█ ░█▄▄▄█ ░█▄▄▄█
"
terminal_width=$(tput cols) # 현재 터미널의 너비(컬럼 수)를 가져옵니다.
padding_length=$(((terminal_width - ${#text_art}) / 2)) # 중앙 패딩
padding=$(printf "%*s" $padding_length "")
echo -e "\033[38;5;208m$padding$text_art\033[0m" # 텍스트 아트 출력
custom_echo "GITHUB : github.com/mkdir-sweetiepie" "green" # 깃헙 주소 출력
custom_echo "RO:BIT 18th JiHyeon Hong" "green" # 이름 출력
custom_echo "Install ROS2 Humble" "green" # Ros 설치 정보 출력
loading_animation
source /etc/os-release # 현재 Ubuntu 버전을 가져옵니다.
ubuntu=$VERSION_ID
cv="Current Version Of Ubuntu Is : ${ubuntu}" # 현재 Ubuntu 버전을 출력합니다.
custom_echo "${cv}" "green"
if [[ $ubuntu == "20.04" ]]; then
custom_echo "ROS Humble available!" "green"
custom_echo "### ROS Humble is an upcoming release of the Robot Operating System (ROS). ###" "yellow"
custom_echo "### It is being developed for Ubuntu 20.04 and aims to further expand the capabilities of ROS for robotics applications. ###" "yellow"
read -n 1 -p "Press Enter to start ROS installation, or any other key to exit..."
if [[ $REPLY == "" ]]; then
echo "[Check UTF-8]"
locale
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale
custom_echo "Installing ROS Humble" "green"
loading_animation
sudo apt-get update && sudo apt upgrade -y
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y universe
sudo apt-get install -y curl gnupg2 lsb-release build-essential
sudo apt update
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
custom_echo "adding key" "green"
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list >/dev/null
sudo apt update
custom_echo "installing ROS-humble-desktop-full" "green"
sudo apt install -y ros-humble-desktop-full
custom_echo "setting bashrc" "green"
echo "source /opt/ros/humble/setup.bash" >>~/.bashrc
source ~/.bashrc
sudo apt update && sudo apt install -y \
python3-flake8-docstrings \
python3-pip \
python3-pytest-cov \
ros-dev-tools
python3 -m pip install -U \
flake8-blind-except \
flake8-builtins \
flake8-class-newline \
flake8-comprehensions \
flake8-deprecated \
flake8-import-order \
flake8-quotes \
"pytest>=5.3" \
pytest-repeat \
pytest-rerunfailures
custom_echo "ROS Humble Installed!" "green"
else
custom_echo "Installation Canceled" "red"
fi
else
custom_echo "Unsupported Ubuntu version!" "red"
fi
exit 0