|
1 | | -#! /usr/bin/env bash |
| 1 | +#!/usr/bin/env bash |
2 | 2 |
|
3 | | -### Installation script for ROS 2 Jazzy |
| 3 | +### Installation script for ROS 2 (tested with Humble and Jazzy) |
4 | 4 | ## Credits to @anadon |
5 | 5 |
|
| 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 | + |
6 | 14 | if (( EUID == 0 )); then |
7 | 15 | SUDO="" |
8 | 16 | else |
9 | 17 | SUDO="sudo" |
10 | 18 | fi |
11 | 19 |
|
12 | | - |
13 | 20 | $SUDO add-apt-repository universe |
14 | 21 | $SUDO apt update |
15 | 22 |
|
16 | 23 | export DEBIAN_FRONTEND=noninteractive |
17 | 24 |
|
18 | 25 | 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" |
21 | 28 |
|
22 | 29 | $SUDO apt install -y $DEPS_0 |
23 | 30 |
|
24 | | - |
25 | 31 | $SUDO locale-gen en_US en_US.UTF-8 |
26 | 32 | $SUDO update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 |
27 | 33 | export LANG=en_US.UTF-8 |
28 | 34 | export LC_ALL=en_US.UTF-8 |
29 | 35 |
|
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 |
34 | 50 |
|
35 | 51 | $SUDO apt install -y $DEPS_1 |
36 | 52 |
|
37 | 53 | $SUDO curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg |
38 | 54 |
|
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 |
41 | 56 |
|
42 | 57 | $SUDO apt update |
43 | 58 | $SUDO apt install -y $DEPS_2 |
44 | 59 |
|
45 | 60 | pip install -r requirements.txt |
46 | 61 |
|
47 | | - |
48 | 62 | pushd gtsam || exit 1 |
49 | | - |
50 | 63 | 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 |
52 | 65 | cd build || exit 1 |
53 | 66 | cmake .. |
54 | | - # make check (optional, runs unit tests) |
| 67 | +make -j$(nproc) |
55 | 68 | $SUDO make install |
56 | | - |
57 | 69 | popd || exit 1 |
58 | 70 |
|
59 | 71 | ################## |
60 | 72 | # ROS 2 OS SETUP # |
61 | 73 | ################## |
62 | 74 |
|
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" |
65 | 76 |
|
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 |
73 | 82 |
|
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 |
76 | 90 |
|
77 | 91 | pushd cslam_interfaces || exit 1 |
78 | 92 | 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 |
81 | 97 | popd || exit 1 |
82 | 98 |
|
83 | 99 | colcon build |
84 | 100 | colcon test |
85 | 101 |
|
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