-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup_tools.sh
executable file
·348 lines (299 loc) · 9.89 KB
/
setup_tools.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
#!/bin/bash
APP_PATH=$HOME/.local/share/JetBrains/Toolbox/apps
PURPLE='\033[0;35m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
LIGHT_GREEN='\033[1;32m'
NC='\033[0m' # No Color
echo_info() {
echo -e $PURPLE$1$NC
}
echo_success() {
echo -e $LIGHT_GREEN$1$NC
}
echo_warning() {
echo -e $YELLOW$1$NC
}
echo_failure() {
echo -e $RED$1$NC
}
print_divider() {
TITLE=$(echo "$1" | tr [:lower:] [:upper:])
STATUS=$(echo "$2" | tr [:lower:] [:upper:])
if [ $STATUS == FINISHED ]; then
printf "$LIGHT_GREEN─%.0s$NC" $(seq 1 103)
printf "\n"
printf "$LIGHT_GREEN%-90s : %10s$NC\n" "$TITLE" "$STATUS"
else
printf "$PURPLE%-90s : %10s$NC\n" "$TITLE" "$STATUS"
printf "$PURPLE─%.0s$NC" $(seq 1 103)
printf "\n"
fi
}
install_ros() {
print_divider "Installing ROS packages" started
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt-get update
if [ $(lsb_release -sc) == focal ]; then
ROS_DISTRO=noetic
elif [ $(lsb_release -sc) == bionic ]; then
ROS_DISTRO=melodic
else
echo_failure "Only Ubuntu 20.04 and 18.04 are supported for ROS installation"
return
fi
sudo apt-get install -y ros-$ROS_DISTRO-desktop ros-$ROS_DISTRO-rosmon ros-$ROS_DISTRO-behaviortree-cpp-v3 \
ros-$ROS_DISTRO-ros-control ros-$ROS_DISTRO-ros-controllers ros-$ROS_DISTRO-moveit ros-$ROS_DISTRO-std-srvs \
ros-$ROS_DISTRO-trac-ik-lib ros-$ROS_DISTRO-eigen-conversions ros-$ROS_DISTRO-rosbridge-suite
print_divider "Successfully installed ROS $ROS_DISTRO packages" finished
# Create ROS workspace
print_divider "Set up ROS workspace" started
source /opt/ros/$ROS_DISTRO/setup.bash
if [ -d $HOME/catkin_ws ]; then
echo_info "Found default ROS workspace $HOME/catkin_ws"
else
echo_info "Creating ROS workspace $HOME/catkin_ws ..."
mkdir -p $HOME/catkin_ws/src
echo_success "catkin_ws built"
fi
if [ ! -d $HOME/RoTools ]; then
echo_failure "RoTools should be stored in the $HOME folder!"
fi
cd $HOME/RoTools && ./make_symlink.sh
print_divider "Successfully set up ROS workspace" finished
}
install_cartesio() {
print_divider "Installing CartesI/O ..." started
if [ $(lsb_release -sc) == focal ]; then
LINK=https://github.com/ADVRHumanoids/XBotControl/releases/download/2.0-devel-core-updated/focal-latest.tar.gz
elif [ $(lsb_release -sc) == bionic ]; then
LINK=https://github.com/ADVRHumanoids/XBotControl/releases/download/2.0-devel-core-updated/bionic-latest.tar.xz
else
echo_failure "Only Ubuntu 20.04 and 18.04 are supported for CartesI/O installation"
return
fi
cd ~/Downloads
wget -cO cartesio.tar.gz $LINK
tar -xzf cartesio.tar.gz
DIR=$(find ./$(lsb_release -sc)-* -maxdepth 2 -type d -name $(lsb_release -sc)-\* -print | head -n1)
cd $DIR
echo $PWD
./install.sh
grep -q "CartesI/O" $HOME/.bashrc
if [ $? -ne 0 ]; then
echo "" >>~/.bashrc
echo "# CartesI/O" >>~/.bashrc
echo "source /opt/xbot/setup.sh" >>~/.bashrc
fi
print_divider "Successfully installed CartesI/O $(lsb_release -sc)" finished
}
install_hpp() {
print_divider "Installing Humanoid Path Planner ..." started
sources $HOME/.bashrc
if [ $(lsb_release -sc) == focal ]; then
PYVER=38
PYCODE=3.8
elif [ $(lsb_release -sc) == bionic ]; then
PYVER=36
PYCODE=3.6
else
echo_failure "Only Ubuntu 20.04 and 18.04 are supported for HPP installation"
return
fi
sudo sh -c 'echo "deb [arch=amd64] http://robotpkg.openrobots.org/packages/debian/pub $(lsb_release -sc) robotpkg" > /etc/apt/sources.list.d/robotpkg.list'
curl http://robotpkg.openrobots.org/packages/debian/robotpkg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y robotpkg-py${PYVER}-hpp-manipulation-corba robotpkg-py${PYVER}-qt5-hpp-gepetto-viewer \
robotpkg-py${PYVER}-hpp-tutorial robotpkg-py${PYVER}-qt5-hpp-gui robotpkg-py${PYVER}-qt5-hpp-plot \
robotpkg-py${PYVER}-hpp-environments robotpkg-py${PYVER}-eigenpy robotpkg-hpp-fcl
grep -q "HPP" $HOME/.bashrc
if [ $? -ne 0 ]; then
echo "" >>~/.bashrc
echo "# HPP" >>~/.bashrc
echo "export PATH=/opt/openrobots/bin:\$PATH" >>~/.bashrc
echo "export LD_LIBRARY_PATH=/opt/openrobots/lib:\$LD_LIBRARY_PATH" >>~/.bashrc
echo "export PYTHONPATH=/opt/openrobots/lib/python$PYCODE/site-packages:\$PYTHONPATH" >>~/.bashrc
echo "export ROS_PACKAGE_PATH=/opt/openrobots/share:\$ROS_PACKAGE_PATH" >>~/.bashrc
echo "export CMAKE_PREFIX_PATH=/opt/openrobots:\$CMAKE_PREFIX_PATH" >>~/.bashrc
echo "export PKG_CONFIG_PATH=/opt/openrobots:\$PKG_CONFIG_PATH" >>~/.bashrc
fi
print_divider "Successfully installed Humanoid Path Planner for Python $PYCODE" finished
}
install_pinocchio() {
print_divider "Installing pinocchio ..." started
sources $HOME/.bashrc
if [ $(lsb_release -sc) == focal ]; then
PYCODE=3.8
elif [ $(lsb_release -sc) == bionic ]; then
PYCODE=3.6
else
echo_failure "Only Ubuntu 20.04 and 18.04 are supported for Pinocchio installation"
return
fi
cd ~
git clone --recursive https://github.com/stack-of-tasks/pinocchio
cd pinocchio/ && git checkout master
mkdir build && cd build
cmake -DBUILD_WITH_COLLISION_SUPPORT=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j4
sudo make install
grep -q "pinocchio" $HOME/.bashrc
if [ $? -ne 0 ]; then
echo "" >>~/.bashrc
echo "# pinocchio" >>~/.bashrc
echo "export PATH=/usr/local/bin:\$PATH" >>~/.bashrc
echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:\$PKG_CONFIG_PATH" >>~/.bashrc
echo "export LD_LIBRARY_PATH=/usr/local/lib:\$LD_LIBRARY_PATH" >>~/.bashrc
echo "export PYTHONPATH=/usr/local/lib/python$PYCODE/site-packages:\$PYTHONPATH" >>~/.bashrc
echo "export CMAKE_PREFIX_PATH=/usr/local:\$CMAKE_PREFIX_PATH" >>~/.bashrc
fi
print_divider "Successfully installed pinocchio" finished
}
install_ocs2() {
print_divider "Installing OCS2 ..." started
sources $HOME/.bashrc
if [ $(lsb_release -sc) == focal ]; then
PYCODE=3.8
else
echo_failure "Only Ubuntu 20.04 is supported for OCS2 installation"
return
fi
sudo apt-get update
sudo apt-get install -y libglpk-dev ros-noetic-pybind11-catkin python3-catkin-tools doxygen doxygen-latex \
liburdfdom-dev liboctomap-dev libassimp-dev ros-noetic-rqt-multiplot python3-sphinx checkinstall ros-noetic-grid-map-msgs
cd ~
git clone https://github.com/raisimTech/raisimLib.git
cd raisimLib/
mkdir build && cd build
cmake .. -DRAISIM_EXAMPLE=ON -DRAISIM_PY=ON -DPYTHON_EXECUTABLE=/usr/bin/python3
make -j4
cd ~/catkin_ws/src/
git clone https://github.com/leggedrobotics/ocs2.git
git clone https://github.com/leggedrobotics/ocs2_robotic_assets.git
cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE=RelWithDebInfo
print_divider "Successfully installed OCS2" finished
}
install_python() {
print_divider "Installing Python packages" started
sudo apt-get install patchelf
pip install -U mujoco imageio
grep -q "RoTools/src" $HOME/.bashrc
if [ $? -ne 0 ]; then
echo_info "Adding $HOME/RoTools/src to PYTHONPATH ..."
echo "" >> ~/.bashrc
echo "# RoTools" >> ~/.bashrc
echo "export PYTHONPATH=$HOME/RoTools/src:\$PYTHONPATH" >> ~/.bashrc
echo_success "Successfully add $HOME/RoTools/src to PYTHONPATH"
else
echo_info "$HOME/RoTools/src has already been added to PYTHONPATH"
fi
print_divider "Python packages installed" finished
}
install_sublime_text() {
print_divider "Installing Sublime Text ..." started
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install -y sublime-text
print_divider "Successfully installed Sublime Text" finished
}
install_jetbrains_toolbox() {
print_divider "Installing JetBrains Toolbox ..." started
cd ~/Downloads
wget -cO jetbrains-toolbox.tar.gz "https://data.services.jetbrains.com/products/download?platform=linux&code=TBA"
tar -xzf jetbrains-toolbox.tar.gz
DIR=$(find . -maxdepth 1 -type d -name jetbrains-toolbox-\* -print | head -n1)
cd $DIR
./jetbrains-toolbox
cd ..
rm -r $DIR
rm jetbrains-toolbox.tar.gz
print_divider "Successfully installed JetBrains Toolbox" finished
}
help() {
# Display Help
echo "===== RoTools Setup Tools Usage Guide ====="
echo "Syntax: setup_tools.sh [option]"
echo "options:"
echo "no option Install all packages, recommended for new machine."
echo "-h | --help Print this Help."
echo "--ros Install ROS only."
echo "--cio Install CartesIO only."
echo "--hpp Install HPP only."
echo "--pin Install pinocchio only."
echo "--ocs2 Install OCS2 only."
echo "--py Install Python packages only."
echo "--sub Install Sublime Text only."
echo "--jet Install JetBrains Toolbox only."
}
if [ $# -eq 1 ]; then
case "$1" in
-h | --help)
help
exit
;;
*) # Pass
;;
esac
fi
sudo apt-get update
sudo apt-get install -y wget apt-transport-https libmatio-dev screen
if [ $# -eq 0 ]; then
install_ros
install_cartesio
install_hpp
install_pinocchio
# install_ocs2 # Temporary suspend this due to comparability error
install_python
install_sublime_text
install_jetbrains_toolbox
else
case "$1" in
-h | --help)
help
exit
;;
--ros)
install_ros
exit
;;
--cio)
install_cartesio
exit
;;
--hpp)
install_hpp
exit
;;
--pin)
install_hpp
install_pinocchio
exit
;;
--ocs2)
install_hpp
install_pinocchio
install_ocs2
exit
;;
--py)
install_python
exit
;;
--sub)
install_sublime_text
exit
;;
--jet)
install_jetbrains_toolbox
exit
;;
*) # Invalid option
help
exit
;;
esac
fi
exit 0