-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
132 lines (113 loc) · 4.79 KB
/
Copy pathsetup.sh
File metadata and controls
132 lines (113 loc) · 4.79 KB
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
#!/usr/bin/env bash
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
# ===== User settings (modify if needed) =====
export ROS_DISTRO="noetic"
export APP_USER="robotics"
# ===== Repository URLs =====
export RANGE_LIBC_REPO="https://github.com/gftabor/range_libc.git"
export ROBOT_DEPS_REPO="https://github.com/trhermans/alg_fnd_robot_dependencies.git"
export MUSHR_REPO="https://github.com/trhermans/alg_fnd_mushr.git"
# ===== Root permission check =====
if [[ $EUID -ne 0 ]]; then
echo "Please run as root: sudo bash $0"
exit 1
fi
# ===== Install Desktop environment on Ubuntu 20.04 server (ARM64) =====
echo "[1/10] Installing full desktop environment (ubuntu-desktop)..."
apt update -y
apt install -y ubuntu-desktop
# ===== Install basic packages and set repositories =====
echo "[2/10] Installing basic packages and setting repositories..."
apt update -y
apt install -y build-essential cmake software-properties-common curl gnupg lsb-release
add-apt-repository -y universe
add-apt-repository -y multiverse
apt update -y
# ===== Ensure APP_USER exists =====
if ! id -u "${APP_USER}" >/dev/null 2>&1; then
echo "[!] User ${APP_USER} not found. Creating..."
adduser --disabled-password --gecos "" "${APP_USER}"
usermod -aG sudo "${APP_USER}" || true
fi
# ===== Add ROS APT repository =====
echo "[3/10] Adding ROS Noetic APT repository..."
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 | apt-key add -
apt update -y
# ===== Install ROS and dependencies =====
echo "[4/10] Installing ROS and dependency packages..."
apt install -y --no-install-recommends \
python3-catkin-tools python3-dev python3-numpy python3-tk python3-pip \
python3-rosdep python3-rosinstall python3-rosinstall-generator python3-vcstool \
python3-wstool ros-${ROS_DISTRO}-desktop \
ros-${ROS_DISTRO}-ackermann-msgs ros-${ROS_DISTRO}-fake-localization ros-${ROS_DISTRO}-joy \
ros-${ROS_DISTRO}-map-server ros-${ROS_DISTRO}-realsense2-description ros-${ROS_DISTRO}-robot-state-publisher \
ros-${ROS_DISTRO}-serial ros-${ROS_DISTRO}-urg-node ros-${ROS_DISTRO}-xacro \
cython3 emacs-gtk
# ===== Add ROS source to user's .bashrc =====
echo "[5/10] Adding ROS source to ${APP_USER}'s .bashrc..."
sudo -u "${APP_USER}" bash -lc "
grep -q 'source /opt/ros/${ROS_DISTRO}/setup.bash' ~/.bashrc || \
echo 'source /opt/ros/${ROS_DISTRO}/setup.bash' >> ~/.bashrc
"
# ===== Initialize rosdep =====
echo "[6/10] Initializing/updating rosdep..."
if [[ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]]; then
rosdep init
fi
sudo -u "${APP_USER}" rosdep update
# ===== Clone workspaces/repositories =====
echo "[7/10] Cloning workspaces/repositories..."
sudo -u "${APP_USER}" mkdir -p "/home/${APP_USER}/dependencies_ws/src" "/home/${APP_USER}/mushr_ws/src"
# range_libc
if [[ ! -d "/home/${APP_USER}/range_libc/.git" ]]; then
sudo -u "${APP_USER}" git clone "${RANGE_LIBC_REPO}" "/home/${APP_USER}/range_libc"
fi
# alg_fnd_robot_dependencies
if [[ ! -d "/home/${APP_USER}/dependencies_ws/src/alg_fnd_robot_dependencies/.git" ]]; then
sudo -u "${APP_USER}" git clone "${ROBOT_DEPS_REPO}" \
"/home/${APP_USER}/dependencies_ws/src/alg_fnd_robot_dependencies"
fi
sudo -u "${APP_USER}" bash -lc "
cd /home/${APP_USER}/dependencies_ws/src/alg_fnd_robot_dependencies
git submodule update --init --recursive
"
# alg_fnd_mushr
if [[ ! -d "/home/${APP_USER}/mushr_ws/src/alg_fnd_mushr/.git" ]]; then
sudo -u "${APP_USER}" git clone "${MUSHR_REPO}" \
"/home/${APP_USER}/mushr_ws/src/alg_fnd_mushr"
fi
# ==== Install range_libc Python wrapper ====
echo "[8/10] Installing range_libc Python wrapper..."
if [ -d "/home/${APP_USER}/range_libc/pywrapper" ]; then
sudo -u "${APP_USER}" bash -lc "
cd /home/${APP_USER}/range_libc/pywrapper
sudo python3 setup.py install
"
fi
# ===== Catkin build (dependencies_ws → mushr_ws) =====
echo "[9/10] Catkin build (dependencies_ws → mushr_ws)..."
# dependencies_ws
sudo -u "${APP_USER}" bash -lc "
set -e
source /opt/ros/${ROS_DISTRO}/setup.bash
cd /home/${APP_USER}/dependencies_ws
catkin build
grep -q 'source /home/${APP_USER}/dependencies_ws/devel/setup.bash' /home/${APP_USER}/.bashrc || \
echo 'source /home/${APP_USER}/dependencies_ws/devel/setup.bash' >> /home/${APP_USER}/.bashrc
"
# mushr_ws
sudo -u "${APP_USER}" bash -lc "
set -e
source /opt/ros/${ROS_DISTRO}/setup.bash
source /home/${APP_USER}/dependencies_ws/devel/setup.bash
cd /home/${APP_USER}/mushr_ws
catkin build
grep -q 'source /home/${APP_USER}/mushr_ws/devel/setup.bash' /home/${APP_USER}/.bashrc || \
echo 'source /home/${APP_USER}/mushr_ws/devel/setup.bash' >> /home/${APP_USER}/.bashrc
"
# ===== Final cleanup =====
echo "[10/10] All tasks completed. Cleaning up..."
rm -- "$0"