Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/xXThanatosXx/MobileRobot/llms.txt

Use this file to discover all available pages before exploring further.

ros2_install.sh is the primary installation script for the MobileRobot course. It fully automates ROS2 Humble setup on Ubuntu 22.04 — handling locale configuration, APT source registration, package installation, colcon workspace creation, rosdep initialization, and shell environment configuration — so students can go from a fresh Ubuntu install to a working ROS2 environment in a single command.
If you have another ROS distro already installed, comment out its source /opt/ros/<OTHER_DISTRO>/setup.bash line in your ~/.bashrc before running this script. Running two ROS environments simultaneously causes conflicts that are difficult to debug.

Script Location

The script lives at Scripts/ros2_install.sh in the MobileRobot repository.

Running the Script

Navigate to the directory where you downloaded the script, make it executable, and run it:
sudo chmod +x ros2_install.sh
./ros2_install.sh
The script prints a confirmation prompt immediately after launch and then waits up to 10 seconds for you to press Enter (or CTRL+C to abort). Use that window to double-check the displayed configuration before the installation begins.

Configurable Variables

Three variables near the top of the script control what gets installed and where the workspace is created. Edit them before running if you need different values:
VariableDefaultPurpose
name_ros_version'humble'ROS2 distribution name used in every package and path reference
ros2_pkg'desktop'Package variant to install — desktop includes GUI tools such as RViz; alternatives are desktop-full and ros-base
name_workspace'colcon_ws'Name of the colcon workspace directory created under $HOME

Step-by-Step Execution Flow

1

Distro conflict warning

The script immediately prints a warning reminding you to comment out any existing ROS distro source lines in ~/.bashrc, then pauses for you to press Enter.
2

Display configuration and confirm

The resolved values of name_ros_version, ros2_pkg, and name_workspace are printed so you can verify them. The script then waits up to 10 seconds — press Enter to continue or CTRL+C to cancel.
3

Set locale

Ensures the system locale is correctly configured for ROS2:
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
4

Set up APT sources

Installs prerequisite tools, downloads the official ROS2 GPG signing key, and registers the ROS2 APT repository:
sudo rm -rf /var/lib/apt/lists/* && sudo apt update && sudo apt install -y curl gnupg2 lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key \
    -o /usr/share/keyrings/ros-archive-keyring.gpg
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture) \
    signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] \
    http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" \
    | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null'
sudo apt update
5

Install ROS2 Humble Desktop

Installs the full desktop variant of ROS2 Humble (includes RViz, rqt, and all core libraries):
sudo apt install -y ros-humble-desktop
6

Install Python tooling

Sources the freshly installed ROS2 environment and installs the Python utilities needed for building and managing packages:
source /opt/ros/humble/setup.sh
sudo apt install -y python3-argcomplete \
    python3-colcon-common-extensions \
    python3-vcstool \
    python3-rosdep2
7

Create the colcon workspace

Creates the colcon_ws workspace directory (or whichever name you set in name_workspace) and runs an initial build to verify the setup:
mkdir -p $HOME/colcon_ws/src
cd $HOME/colcon_ws
colcon build --symlink-install
8

Update rosdep

Fetches the latest rosdep package index so dependency resolution works correctly:
rosdep update
9

Configure ~/.bashrc

Appends convenience aliases, ROS2 source lines, workspace overlay, colcon shell completion, and the ROS_DOMAIN_ID export to ~/.bashrc — see the full block below.

~/.bashrc Additions

After the installation completes, the script appends the following lines to your ~/.bashrc:
alias nb='nano ~/.bashrc'
alias sb='source ~/.bashrc'

source /opt/ros/humble/setup.bash
source ~/colcon_ws/install/setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash

export ROS_DOMAIN_ID=0
LinePurpose
alias nbOpens ~/.bashrc in nano for quick editing
alias sbRe-sources ~/.bashrc in the current shell without restarting the terminal
source /opt/ros/humble/setup.bashPuts all ROS2 Humble executables and libraries on your PATH / PYTHONPATH
source ~/colcon_ws/install/setup.bashOverlays your local workspace packages on top of the ROS2 install
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bashEnables TAB completion for colcon commands
export ROS_DOMAIN_ID=0Scopes DDS discovery to domain 0; change this if running multiple robots on the same network
ROS_DOMAIN_ID=0 is the default and works for single-machine development. If you are running multiple robots or developers on the same LAN, assign each machine a unique domain ID (0–101) to prevent cross-talk between unrelated nodes.

Build docs developers (and LLMs) love