Skip to content

Commit af17c4b

Browse files
authored
Merge pull request #57 from TannerGilbert/main
feat: Make build-everything.sh usable for more ROS versions
2 parents cbbb4bb + 10daa6e commit af17c4b

1 file changed

Lines changed: 50 additions & 33 deletions

File tree

build-everything.sh

100644100755
Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,105 @@
1-
#! /usr/bin/env bash
1+
#!/usr/bin/env bash
22

3-
### Installation script for ROS 2 Jazzy
3+
### Installation script for ROS 2 (tested with Humble and Jazzy)
44
## Credits to @anadon
55

6+
set -e
7+
8+
# Usage: ./install.sh [add_ros_setup (true/false)] [shell_type (bash/zsh)]
9+
ADD_ROS_SETUP=${1:-true}
10+
SHELL_TYPE=${2:-bash}
11+
RC_FILE="$HOME/.${SHELL_TYPE}rc"
12+
WORKSPACE_DIR="$(pwd)"
13+
614
if (( EUID == 0 )); then
715
SUDO=""
816
else
917
SUDO="sudo"
1018
fi
1119

12-
1320
$SUDO add-apt-repository universe
1421
$SUDO apt update
1522

1623
export DEBIAN_FRONTEND=noninteractive
1724

1825
DEPS_0="curl git sudo apt-utils dialog locales"
19-
DEPS_1="libboost-all-dev cmake libtbb-dev intel-mkl-full python3-rosdep python3-colcon-common-extensions sudo git software-properties-common python3-dev python3-full python3-pip"
20-
DEPS_2="ros-dev-tools ros-jazzy-desktop ros-jazzy-rtabmap ros-jazzy-rtabmap-msgs ros-jazzy-navigation2 ros-jazzy-nav2-bringup ros-jazzy-nav2-minimal-tb* ros-jazzy-perception-pcl ros-jazzy-rtabmap-conversions ros-rolling-cv-bridge "
26+
DEPS_1="libboost-all-dev cmake libtbb-dev intel-mkl-full python3-rosdep python3-colcon-common-extensions sudo git software-properties-common python3-dev python3-full python3-pip"
27+
DEPS_2="ros-dev-tools ros-$ROS_DISTRO-desktop ros-$ROS_DISTRO-rtabmap ros-$ROS_DISTRO-rtabmap-msgs ros-$ROS_DISTRO-navigation2 ros-$ROS_DISTRO-nav2-bringup ros-$ROS_DISTRO-perception-pcl ros-$ROS_DISTRO-rtabmap-conversions ros-rolling-cv-bridge"
2128

2229
$SUDO apt install -y $DEPS_0
2330

24-
2531
$SUDO locale-gen en_US en_US.UTF-8
2632
$SUDO update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
2733
export LANG=en_US.UTF-8
2834
export LC_ALL=en_US.UTF-8
2935

30-
git clone https://github.com/lajoiepy/cslam.git
31-
git clone https://github.com/lajoiepy/cslam_interfaces.git
32-
git clone https://github.com/lajoiepy/cslam_experiments.git
33-
git clone https://github.com/borglab/gtsam.git
36+
declare -A REPOS=(
37+
["cslam"]="https://github.com/lajoiepy/cslam.git"
38+
["cslam_interfaces"]="https://github.com/lajoiepy/cslam_interfaces.git"
39+
["cslam_experiments"]="https://github.com/lajoiepy/cslam_experiments.git"
40+
["gtsam"]="https://github.com/borglab/gtsam.git"
41+
)
42+
43+
for repo in "${!REPOS[@]}"; do
44+
if [ ! -d "$repo" ]; then
45+
git clone "${REPOS[$repo]}"
46+
else
47+
echo "Repo $repo already cloned. Skipping."
48+
fi
49+
done
3450

3551
$SUDO apt install -y $DEPS_1
3652

3753
$SUDO curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
3854

39-
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
40-
55+
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
4156

4257
$SUDO apt update
4358
$SUDO apt install -y $DEPS_2
4459

4560
pip install -r requirements.txt
4661

47-
4862
pushd gtsam || exit 1
49-
5063
echo "WARNING!!! This deviates from the Swarm-Slam instructions by using gtsam v4.2 and not 4.1.1."
51-
mkdir build
64+
mkdir -p build
5265
cd build || exit 1
5366
cmake ..
54-
# make check (optional, runs unit tests)
67+
make -j$(nproc)
5568
$SUDO make install
56-
5769
popd || exit 1
5870

5971
##################
6072
# ROS 2 OS SETUP #
6173
##################
6274

63-
echo "WARNING!!! This deviates from Swarm-Slam instructions by using ROS 2 Jazzy instead of Foxy"
64-
echo "WARNING!!! This is setting up a one-time configuration change because it is destructive to your environment. This installer is REQUIRING that you take manual action to make this change permenent."
75+
echo "WARNING!!! Using newer ROS 2 versions (like Humble or Jazzy) instead of Foxy"
6576

66-
# Replace ".bash" with your shell if you're not using bash
67-
# Possible values are: setup.bash, setup.sh, setup.zsh
68-
69-
echo 'source "/opt/ros/jazzy/setup.bash"' >> ~/.bashrc
70-
source "/opt/ros/jazzy/setup.bash"
71-
72-
$SUDO rosdep init
77+
if [[ "$ADD_ROS_SETUP" == "true" ]]; then
78+
echo "Adding ROS environment setup to $RC_FILE"
79+
echo 'source "/opt/ros/$ROS_DISTRO/setup.'"$SHELL_TYPE"'"' >> "$RC_FILE"
80+
source "/opt/ros/$ROS_DISTRO/setup.$SHELL_TYPE"
81+
fi
7382

74-
rosdep update
75-
rosdep install --from-paths src -y --ignore-src --rosdistro jazzy
83+
$SUDO rosdep init || echo "rosdep already initialized"
84+
if ! rosdep update; then
85+
echo "WARNING: rosdep update failed — continuing anyway"
86+
fi
87+
if ! rosdep install --from-paths src -y --ignore-src --rosdistro $ROS_DISTRO; then
88+
echo "WARNING: rosdep install failed — continuing anyway"
89+
fi
7690

7791
pushd cslam_interfaces || exit 1
7892
colcon build
79-
echo 'source "/Swarm-SLAM/cslam_interfaces/install/setup.bash"' >> "$HOME/.bashrc"
80-
source "/Swarm-SLAM/cslam_interfaces/install/setup.bash"
93+
if [[ "$ADD_ROS_SETUP" == "true" ]]; then
94+
echo 'source "'"$WORKSPACE_DIR"'/cslam_interfaces/install/setup.'"$SHELL_TYPE"'"' >> "$RC_FILE"
95+
source "$WORKSPACE_DIR/cslam_interfaces/install/setup.$SHELL_TYPE"
96+
fi
8197
popd || exit 1
8298

8399
colcon build
84100
colcon test
85101

86-
echo 'source "/Swarm-SLAM/install/setup.bash"' >> "$HOME/.bashrc"
87-
source "/Swarm-SLAM/install/setup.bash"
88-
102+
if [[ "$ADD_ROS_SETUP" == "true" ]]; then
103+
echo 'source "'"$WORKSPACE_DIR"'/install/setup.'"$SHELL_TYPE"'"' >> "$RC_FILE"
104+
source "$WORKSPACE_DIR/install/setup.$SHELL_TYPE"
105+
fi

0 commit comments

Comments
 (0)