forked from SRA-VJTI/MARIO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallations.sh
executable file
·298 lines (279 loc) · 12 KB
/
installations.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
!/usr/bin/env bash
set -e
red=`tput setaf 1`
green=`tput setaf 2`
blue=`tput setaf 4`
reset=`tput sgr0`
echo "Installing ESP IDF"
_shell_="${0##*/}"
# Check whether esp-idf has already been installed
if [ -d $HOME/esp/esp-idf ]; then
echo "${red}======================$reset"
echo "You already have installed esp-idf!"
echo "${blue}======================$reset"
else
# System Detection and ESP-IDF Installation
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
sudo apt update && sudo apt upgrade -y
sudo usermod -a -G dialout $USER
sudo apt install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 -y
sudo apt install python3-venv
;;
Darwin*)
if brew --version | grep -q 'Homebrew'; then
echo "${red}======================$reset"
echo "Homebrew is already installed"
echo "${blue}======================$reset"
else
echo "installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "${blue}======================$reset"
echo "homebrew installed successfully"
echo "${blue}======================$reset"
fi
brew install git cmake ninja dfu-util python3
;;
*)
echo "Not supported: ${unameOut}"
exit 1
;;
esac
# Create ESP Directory
mkdir -p "$HOME/esp"
pushd "$HOME"/esp || (echo "Error: Cannot Make Directory" && exit 1)
# Clone ESP-IDF Repository
git clone -b release/v5.1 --recursive https://github.com/espressif/esp-idf.git
cd $HOME/esp/esp-idf
./install.sh esp32
# Check if installation is successful
. $HOME/esp/esp-idf/export.sh
echo "${red}======================$reset"
echo "${red}======================$reset"
echo "${green}Esp Installation Successfull "
# Set IDF Alias
echo "alias get_idf='. $HOME/esp/esp-idf/export.sh'" >> $HOME/."$_shell_"rc
idf.py --version
fi
echo "$reset"
# Clone Mario repository if not already cloned
if [ ! -d $HOME/MARIO ]; then
echo "${blue}======================$reset"
echo "Cloning Mario"
echo "${red}======================$reset"
cd $Home
git clone -b humble --recursive https://github.com/SRA-VJTI/MARIO.git
echo "${blue}======================$reset"
echo "Mario repo cloned successfully"
echo "${red}======================$reset"
else
echo "${red}======================$reset"
echo "Mario repository already exists and is not empty. Skipping cloning."
echo "${red}======================$reset"
fi
# Check the operating system
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
echo "Checking if ROS 2 is installed..."
# Check if ROS 2 is already installed
if ! command -v ros2 &>/dev/null; then
echo "${red}======================$reset"
echo "ROS 2 is not installed. Proceeding with installation..."
# Check for UTF-8 locale
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 # verify settings
# Add ROS 2 repository
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
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
sudo apt upgrade
# Install ROS 2
sudo apt install ros-humble-desktop-full
echo "source /opt/ros/humble/setup.bash" >> $HOME/."$_shell_"rc
# Install additional ROS 2 packages
echo "Installing Additional Ros2 packages"
sudo apt install -y ros-humble-control-msgs ros-humble-control-toolbox ros-humble-joint-state-broadcaster ros-humble-joint-state-publisher ros-humble-joint-state-publisher-gui ros-humble-forward-command-controller ros-humble-robot-state-publisher ros-humble-gazebo-ros2-control ros-humble-robot-controllers ros-humble-robot-controllers-interface ros-humble-robot-controllers-msgs ros-humble-joint-trajectory-controller ros-humble-controller-manager ros-humble-controller-manager-msgs ros-humble-ros2-control ros-humble-gazebo-ros-pkgs ros-humble-gazebo-ros-dbgsym
echo "${red}======================$reset"
echo "ROS 2 installed successfully."
echo "${red}======================$reset"
source $HOME/."$_shell_"rc
else
echo "${red}======================$reset"
echo "ROS 2 is already installed."
echo "${red}======================$reset"
fi
;;
Darwin*)
# Installing mambaforge
echo "Installing mambaforge"
if command -v mamba &>/dev/null; then
echo "${blue}======================$reset"
echo "Mambaforge is already installed"
echo "${red}======================$reset"
else
wget -q https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh -O mambaforge.sh
chmod +x mambaforge.sh
./mambaforge.sh
rm mambaforge.sh
echo "${blue}======================$reset"
echo "Mambaforge installed"
echo "${red}======================$reset"
echo "Initializing Mambaforge"
export PATH="$HOME/mambaforge/bin:$PATH"
mamba init --all
echo "$green Mambaforge initialized. ReOpen a new terminal, and Please re-run the installation script for further configuration"
# exit 0
fi
# Install mamba if not installed already
conda install mamba -c conda-forge
mamba create -n ros_env -c conda-forge
source $HOME/mambaforge/etc/profile.d/conda.sh
conda activate ros_env
conda config --env --add channels conda-forge
conda config --env --add channels robostack-staging
conda config --env --remove channels defaults || true
# Install ROS packages
mamba install ros-humble-desktop-full
mamba install -n ros_env -y ros-humble-control-msgs ros-humble-control-toolbox ros-humble-joint-state-broadcaster ros-humble-joint-state-publisher ros-humble-joint-state-publisher-gui ros-humble-forward-command-controller ros-humble-robot-state-publisher ros-humble-controller-manager ros-humble-controller-manager-msgs ros-humble-joint-trajectory-controller ros-humble-ros2-control
mamba install catkin_tools
echo "${red}======================$reset"
echo "ROS 2 installed successfully."
echo "${red}======================$reset"
;;
*)
echo "ROS 2 installation is not supported on this operating system."
exit 1
;;
esac
# Verify if ros2_ws already exists
if [ -d "$HOME/ros2_ws" ]; then
echo "ros2_ws already exists."
else
case "${unameOut}" in
Linux*)
echo "${red}======================$reset"
echo "Creating a ros2_ws"
echo "${red}======================$reset"
sudo apt update
sudo apt install python3-colcon-common-extensions
echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> $HOME/."$_shell_"rc
mkdir $HOME/ros2_ws
cd $HOME/ros2_ws
mkdir src
colcon build
echo "${red}======================$reset"
echo "ros2_ws successfully setup"
echo "${red}======================$reset"
echo "source $HOME/ros2_ws/install/setup.bash" >> $HOME/."$_shell_"rc
;;
Darwin*)
echo "${blue}======================$reset"
echo "Creating a ros2_ws"
echo "${red}======================$reset"
source $HOME/mambaforge/etc/profile.d/conda.sh
conda activate ros_env
conda install colcon-common-extensions rosdep
# Creating a ros2_ws
mkdir $HOME/ros2_ws
cd $HOME/ros2_ws
sudo chown -R $(whoami) $HOME/ros2_ws
mkdir src
colcon build
echo "${red}======================$reset"
echo "ros2_ws successfully setup"
echo "${red}======================$reset"
;;
*)
echo "ros2_ws couldn't be setup"
exit 1
;;
esac
fi
# Installig Gazebo if not already installed
if [ "$unameOut" == "Linux" ]; then
if ! command -v gazebo &> /dev/null; then
echo "${red}======================$reset"
echo "Installing Gazebo"
echo "${red}======================$reset"
curl -sSL http://get.gazebosim.org | sh
echo "${red}======================$reset"
echo "Gazebo installed successfully"
echo "${red}======================$reset"
else
echo "${red}======================$reset"
echo "Gazebo is already installed"
echo "${red}======================$reset"
fi
fi
# Copying Mario's folders to ros2_ws
cd $HOME/ros2_ws/src
if [[ ! -d "1_chatter_listener" ]]; then
echo "${red}======================$reset"
echo "Copying Mario's folders to ros2_ws"
echo "${red}======================$reset"
cp -r $HOME/MARIO/1_* $HOME/ros2_ws/src
cp -r $HOME/MARIO/2_* $HOME/ros2_ws/src
cp -r $HOME/MARIO/3_* $HOME/ros2_ws/src
cp -r $HOME/MARIO/4_* $HOME/ros2_ws/src
cp -r $HOME/MARIO/activities $HOME/ros2_ws/src
if [[ ! -d "$HOME/ros2_ws_firmware" ]]; then
mkdir -p $HOME/ros2_ws_firmware
cp -r $HOME/MARIO/firmware/* $HOME/ros2_ws_firmware
echo "${red}======================$reset"
echo "$green firmware copied to ros2_ws_firmware $reset"
else
echo "${red}======================$reset"
echo "$green Already copied $reset"
fi
echo "${red}======================$reset"
else
echo "${red}======================$reset"
echo "$green Ros folders are already copied $reset"
fi
cd ..
if [ "$unameOut" == "Darwin" ]; then
source $HOME/mambaforge/etc/profile.d/conda.sh
conda activate ros_env
fi
colcon build
echo "${red}======================$reset"
echo "Successfully copied mario's folders to ros2_ws"
echo "${red}======================$reset"
# Setting up microrosagent
case "${unameOut}" in
Linux*)
echo "Cloning microrosagent"
cd $HOME/ros2_ws/src
git clone -b humble https://github.com/micro-ROS/micro-ROS-Agent.git
cd ..
pip3 install catkin_pkg lark-parser colcon-common-extensions
rosdep install --from-paths src --ignore-src -y
echo "${red}======================$reset"
echo "Done with cloning"
echo "${red}======================$reset"
;;
Darwin*)
echo "${red}======================$reset"
echo "Cloning microrosagent"
echo "${red}======================$reset"
cd $HOME/ros2_ws/src
pip3 install catkin_pkg lark-parser
git clone -b humble https://github.com/micro-ROS/micro-ROS-Agent.git
echo "${red}======================$reset"
echo "Done with cloning microrosagent"
echo "${red}======================$reset"
;;
*)
echo "micros_ws couldn't be setup"
exit 1
;;
esac