install script changes for Ubuntu 25

This commit is contained in:
2026-01-10 22:04:30 +00:00
parent 89cc3f403c
commit 4dc4b5a379

View File

@@ -94,23 +94,42 @@ echo "[STEP 2/$TOTAL_STEPS] Installing ROS 2..."
# Add ROS 2 GPG key
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
# Determine ROS 2 distro based on Ubuntu version
# Determine ROS 2 distro and repository codename based on Ubuntu version
# ROS 2 only has repositories for specific Ubuntu LTS versions
# For newer/unsupported versions, we use the closest compatible LTS repository
if [ "$UBUNTU_VERSION" = "24.04" ]; then
ROS_DISTRO="jazzy"
ROS_UBUNTU_CODENAME="noble"
elif [ "$UBUNTU_VERSION" = "22.04" ]; then
ROS_DISTRO="humble"
ROS_UBUNTU_CODENAME="jammy"
else
echo "[WARN] Ubuntu $UBUNTU_VERSION not officially supported, trying humble"
ROS_DISTRO="humble"
# For Ubuntu versions newer than 24.04, use Jazzy with noble repositories
# This provides best compatibility for cutting-edge Ubuntu versions
UBUNTU_MAJOR=$(echo "$UBUNTU_VERSION" | cut -d. -f1)
if [ "$UBUNTU_MAJOR" -ge 24 ] 2>/dev/null; then
echo "[WARN] Ubuntu $UBUNTU_VERSION not officially supported by ROS 2"
echo "[INFO] Using ROS 2 Jazzy with Ubuntu 24.04 (noble) repositories"
ROS_DISTRO="jazzy"
ROS_UBUNTU_CODENAME="noble"
else
echo "[WARN] Ubuntu $UBUNTU_VERSION not officially supported, trying humble"
ROS_DISTRO="humble"
ROS_UBUNTU_CODENAME="jammy"
fi
fi
echo "[INFO] Using ROS 2 $ROS_DISTRO"
echo "[INFO] Using ROS 2 $ROS_DISTRO (repository: $ROS_UBUNTU_CODENAME)"
# Add repository
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
# Add repository using the compatible Ubuntu codename
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $ROS_UBUNTU_CODENAME main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt-get update
sudo apt-get install -y ros-${ROS_DISTRO}-ros-base ros-${ROS_DISTRO}-geometry-msgs ros-${ROS_DISTRO}-std-msgs ros-${ROS_DISTRO}-nav-msgs ros-${ROS_DISTRO}-sensor-msgs
sudo apt-get install -y ros-${ROS_DISTRO}-ros-base ros-${ROS_DISTRO}-geometry-msgs ros-${ROS_DISTRO}-std-msgs ros-${ROS_DISTRO}-nav-msgs ros-${ROS_DISTRO}-sensor-msgs || {
echo "[ERROR] Failed to install ROS 2 $ROS_DISTRO"
echo "[INFO] This may be due to library incompatibilities with Ubuntu $UBUNTU_VERSION"
echo "[INFO] Consider using Ubuntu 22.04 or 24.04 for full ROS 2 support"
}
# Install ros-gz bridge
sudo apt-get install -y ros-${ROS_DISTRO}-ros-gz || {
@@ -125,9 +144,10 @@ echo "[OK] ROS 2 $ROS_DISTRO installed"
echo ""
echo "[STEP 3/$TOTAL_STEPS] Installing Gazebo..."
# Add Gazebo repository
# Add Gazebo repository (use compatible Ubuntu codename if needed)
GZ_UBUNTU_CODENAME="${ROS_UBUNTU_CODENAME:-$(lsb_release -cs)}"
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg 2>/dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $GZ_UBUNTU_CODENAME main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
sudo apt-get update
# Install Gazebo Harmonic (preferred) or Garden as fallback