Created
April 16, 2026 03:25
-
-
Save MarcoDotIO/18025c2f36f5b66b1d0cb38f518c44a1 to your computer and use it in GitHub Desktop.
Install ROS2 Jazzy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e # Exit on error | |
| echo "=== ROS 2 Jazzy Installation Script ===" | |
| # --- 1. Validate OS --- | |
| if ! grep -q "24.04" /etc/os-release; then | |
| echo "ERROR: This script is intended for Ubuntu 24.04 (Noble)." | |
| exit 1 | |
| fi | |
| # --- 2. Locale setup --- | |
| echo "[1/6] Setting locale..." | |
| sudo apt update | |
| sudo apt install -y 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 | |
| # --- 3. Enable repositories --- | |
| echo "[2/6] Enabling Universe repository..." | |
| sudo apt install -y software-properties-common | |
| sudo add-apt-repository universe -y | |
| # --- 4. Add ROS 2 apt repository --- | |
| echo "[3/6] Adding ROS 2 repository..." | |
| sudo apt update | |
| sudo apt install -y curl | |
| ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest \ | |
| | grep -F "tag_name" | awk -F'"' '{print $4}') | |
| curl -L -o /tmp/ros2-apt-source.deb \ | |
| "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo ${UBUNTU_CODENAME})_all.deb" | |
| sudo dpkg -i /tmp/ros2-apt-source.deb | |
| # --- 5. Install ROS 2 --- | |
| echo "[4/6] Installing ROS 2 Jazzy Desktop..." | |
| sudo apt update | |
| sudo apt install -y ros-jazzy-desktop | |
| # Optional dev tools | |
| echo "[Optional] Installing development tools..." | |
| sudo apt install -y ros-dev-tools | |
| # --- 6. Environment setup --- | |
| echo "[5/6] Configuring environment..." | |
| if ! grep -q "source /opt/ros/jazzy/setup.bash" ~/.bashrc; then | |
| echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc | |
| fi | |
| source /opt/ros/jazzy/setup.bash | |
| # --- 7. rosdep setup --- | |
| echo "[6/6] Initializing rosdep..." | |
| sudo apt install -y python3-rosdep | |
| sudo rosdep init || true | |
| rosdep update | |
| # --- Verification --- | |
| echo "=== Installation Complete ===" | |
| echo "ROS_DISTRO: $ROS_DISTRO" | |
| echo "Run 'printenv ROS_DISTRO' to verify (should be 'jazzy')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment