Skip to content

Commit

Permalink
refactor(scripts): add colcon/ros pkg install to setup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
texhnolyze committed Mar 19, 2024
1 parent f59ab61 commit a2c05b1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,25 @@ In this tutorial, we will learn how to install ROS2 Iron Irwini on Ubuntu 22.04

As ROS works best on Ubuntu, we are using this distribution.
Currently, ROS2 Iron runs on Ubuntu 22.04.
If you are not already using Ubuntu 22.04, consider installing it on your system (perhaps as a dual boot), alternately you can run it in a virtual machine (not recommended, as recently we had some issues with it; https://www.virtualbox.org/) or use the ROS2 docker (https://github.com/timonegk/rosdocked)
If you are not already using Ubuntu 22.04, consider installing it on your system (perhaps as a dual boot), alternately you can run it in a virtual machine (not recommended, as recently we had some issues with it; https://www.virtualbox.org/), a custom ROS2 docker setup (https://github.com/timonegk/rosdocked).

Alternatively you can use a devcontainer :doc:`vscode-dev-container`, with a preconfigured environment and follow those instructions, as these docs do not apply to the devcontainer.

**TLDR**: single command setup
------------------------------

**Prerequirements**
- running Ubuntu 22.04 environment
- running Ubuntu 22.04 environment (native, VM, or custom ROS2 docker setup)
- existing Github account and with SSH key added to your account
- root access to your system (sudo)

If you have not previously setup any of our software stack, you can use the following command to install and setup everything in one go:
If you have not previously set up any of our software stack, you can use the following command to install and setup everything in one go:

.. code-block:: bash
sudo apt install \
clang-format \
cppcheck \
python3-colcon-clean \
python3-colcon-common-extensions \
python3-pip \
python3-rosdep \
python3-vcstool \
ros-iron-desktop-full \
ros-iron-plotjuggler-ros \
ros-iron-rmw-cyclonedds-cpp \
ros-iron-rqt-robot-monitor \
ros-iron-rqt-runtime-monitor \
&& python3 -m pip install \
git+https://github.com/ruffsl/colcon-clean \
git+https://github.com/timonegk/colcon-core.git@colors \
git+https://github.com/timonegk/colcon-notification.git@colors \
git+https://github.com/timonegk/colcon-output.git@colors \
&& mkdir -p ~/git/bitbots \
&& cd ~/git/bitbots \
&& curl -fsSL https://raw.githubusercontent.com/bit-bots/bitbots_main/main/scripts/setup.sh > /tmp/setup.sh \
&& bash /tmp/setup.sh
mkdir -p ~/git/bitbots \
&& cd ~/git/bitbots \
&& curl -fsSL https://raw.githubusercontent.com/bit-bots/bitbots_main/main/scripts/setup.sh > /tmp/setup.sh \
&& bash /tmp/setup.sh
Manual steps with in depth explanation
--------------------------------------
Expand Down
42 changes: 40 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,35 @@ ask_question() {
done
}

setup_ros() {
if (( has_sudo )); then
echo "Setting up ROS 2..."

if [[ ! -f /etc/apt/sources.list.d/ros2.list ]]; then
echo "Adding ROS 2 repository..."
sudo apt install -y curl lsb-release
curl -fsSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key > /usr/share/keyrings/ros-archive-keyring.gpg
sudo sh -c "echo 'deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main' > /etc/apt/sources.list.d/ros2.list"
fi

sudo apt update && sudo apt install -y \
clang-format \
cppcheck \
python3-colcon-clean \
python3-colcon-common-extensions \
python3-pip \
python3-rosdep \
python3-vcstool \
"ros-${ROS_DISTRO}-desktop-full" \
"ros-${ROS_DISTRO}-plotjuggler-ros" \
"ros-${ROS_DISTRO}-rmw-cyclonedds-cpp" \
"ros-${ROS_DISTRO}-rqt-robot-monitor" \
"ros-${ROS_DISTRO}-rqt-runtime-monitor"
else
echo "Please install ROS 2 manually!"
fi
}

setup_repo() {
echo "Setting up bitbots_main repository..."

Expand All @@ -75,7 +104,15 @@ setup_repo() {
fi
}

setup_colcon_workspace() {
setup_colcon() {
echo "Installing/Updating colcon extensions..."

# Install/Update colcon extensions / patches
python3 -m pip install --upgrade --user \
git+https://github.com/timonegk/colcon-core.git@colors \
git+https://github.com/timonegk/colcon-notification.git@colors \
git+https://github.com/timonegk/colcon-output.git@colors

if [[ ! -d "$COLCON_WS/src/bitbots_main" ]]; then
echo "Setting up colcon workspace in $COLCON_WS..."
mkdir -p "$COLCON_WS/src"
Expand Down Expand Up @@ -126,7 +163,8 @@ if [[ ! -d "$meta_dir/.git" ]]; then
in_repo=0
fi

setup_ros
setup_repo
setup_colcon_workspace
setup_colcon
setup_shell_aliases
build_repository

0 comments on commit a2c05b1

Please sign in to comment.