|
| 1 | +#!/bin/bash |
| 2 | +# Script to install development tools and libraries for robotics and simulation |
| 3 | +echo |
| 4 | +echo -e "\033[94m============================================================\033[0m" |
| 5 | +echo -e "\033[94m== One-liner Installation Script for ROS-Gazebo Framework ==\033[0m" |
| 6 | +echo -e "\033[94m============================================================\033[0m" |
| 7 | +echo -e "Requirements: Ubuntu 24.04 LTS Noble" |
| 8 | +echo -e "\033[94m============================================================\033[0m" |
| 9 | + |
| 10 | +echo |
| 11 | +echo -e "\033[96m(1/4) ------------- Updating the System ----------------\033[0m" |
| 12 | +echo "Performing full system upgrade (this might take a while)..." |
| 13 | +sudo sudo apt update && apt full-upgrade -y |
| 14 | + |
| 15 | +echo |
| 16 | +echo -e "\033[96m(2/4) ------------ Install Dependencies ---------------\033[0m" |
| 17 | +echo -e "\033[34mInstalling essential tools and libraries...\033[0m" |
| 18 | +sudo apt install -y \ |
| 19 | + build-essential \ |
| 20 | + cmake \ |
| 21 | + cppcheck \ |
| 22 | + curl \ |
| 23 | + git \ |
| 24 | + gnupg \ |
| 25 | + libeigen3-dev \ |
| 26 | + libgles2-mesa-dev \ |
| 27 | + lsb-release \ |
| 28 | + pkg-config \ |
| 29 | + protobuf-compiler \ |
| 30 | + python3-dbg \ |
| 31 | + python3-pip \ |
| 32 | + python3-venv \ |
| 33 | + qtbase5-dev \ |
| 34 | + ruby \ |
| 35 | + software-properties-common \ |
| 36 | + sudo \ |
| 37 | + cppzmq-dev \ |
| 38 | + wget |
| 39 | + |
| 40 | +echo |
| 41 | +echo -e "\033[96m(3/4) ------------ Install Package Keys ---------------\033[0m" |
| 42 | +echo -e "\033[34mInstalling Signing Keys for ROS and Gazebo...\033[0m" |
| 43 | +# Remove keyring if exists to avoid conflicts |
| 44 | +sudo rm -f /usr/share/keyrings/ros2-latest-archive-keyring.gpg && \ |
| 45 | + sudo rm -rf /etc/apt/sources.list.d/ros2-latest.list |
| 46 | +# Get Keys |
| 47 | +sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key \ |
| 48 | + -o /usr/share/keyrings/ros-archive-keyring.gpg |
| 49 | +sudo wget https://packages.osrfoundation.org/gazebo.gpg \ |
| 50 | + -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg |
| 51 | + |
| 52 | +ARCH=$(dpkg --print-architecture) |
| 53 | +# shellcheck disable=SC1091 |
| 54 | +UBUNTU_CODENAME=$( . /etc/os-release && echo "$UBUNTU_CODENAME") |
| 55 | +REPO="deb [arch=$ARCH signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] \ |
| 56 | +http://packages.ros.org/ros2/ubuntu $UBUNTU_CODENAME main" |
| 57 | +echo "$REPO" | sudo tee /etc/apt/sources.list.d/ros2.list >/dev/null |
| 58 | + |
| 59 | +DISTRO=$(lsb_release -cs) |
| 60 | +REPO="deb [arch=$ARCH signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] \ |
| 61 | +http://packages.osrfoundation.org/gazebo/ubuntu-stable $DISTRO main" |
| 62 | +echo "$REPO" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list >/dev/null |
| 63 | + |
| 64 | +echo |
| 65 | +echo -e "\033[96m(4/4) ------------ Install ROS-Gazebo ---------------\033[0m" |
| 66 | +DIST=jazzy |
| 67 | + |
| 68 | +echo -e "\033[34mInstalling ROS Gazebo framework...\033[0m" |
| 69 | +sudo apt update && apt install -y \ |
| 70 | + python3-rosdep \ |
| 71 | + python3-rosinstall-generator \ |
| 72 | + python3-vcstool \ |
| 73 | + ros-$DIST-desktop \ |
| 74 | + ros-$DIST-ros-gz \ |
| 75 | + ros-$DIST-gz-ros2-control \ |
| 76 | + ros-$DIST-effort-controllers \ |
| 77 | + ros-$DIST-geographic-info \ |
| 78 | + ros-$DIST-joint-state-publisher \ |
| 79 | + ros-$DIST-joy-teleop \ |
| 80 | + ros-$DIST-key-teleop \ |
| 81 | + ros-$DIST-moveit-planners \ |
| 82 | + ros-$DIST-moveit-simple-controller-manager \ |
| 83 | + ros-$DIST-moveit-ros-visualization \ |
| 84 | + ros-$DIST-robot-localization \ |
| 85 | + ros-$DIST-ros2-controllers \ |
| 86 | + ros-$DIST-teleop-tools \ |
| 87 | + ros-$DIST-urdfdom-py \ |
| 88 | + ros-dev-tools |
| 89 | + |
| 90 | +echo |
| 91 | +echo -e "\033[34mSetting up Gazebo source directory...\033[0m" |
| 92 | +mkdir -p /opt/gazebo/src && cd /opt/gazebo/src || exit |
| 93 | +curl -O https://raw.githubusercontent.com/gazebo-tooling/gazebodistro/master/collection-harmonic.yaml |
| 94 | +vcs import < collection-harmonic.yaml |
| 95 | + |
| 96 | +echo -e "\033[34mUpdating package list and installing dependencies...\033[0m" |
| 97 | +# shellcheck disable=SC2046,SC2006 |
| 98 | +sudo apt -y install $(sort -u $(find . -iname 'packages-'`lsb_release -cs`'.apt' -o -iname 'packages.apt' | grep -v '/\.git/') | sed '/gz\|sdf/d' | tr '\n' ' ') |
| 99 | + |
| 100 | +echo -e "\033[34mBuilding the project with colcon...\033[0m" |
| 101 | +cd /opt/gazebo || exit |
| 102 | +# Build gz-physics with limited cores to avoid memory issues |
| 103 | +MAKEFLAGS="-j2" colcon build --cmake-args -DBUILD_TESTING=OFF --merge-install --packages-up-to gz-physics |
| 104 | +# Full build |
| 105 | +colcon build --cmake-args -DBUILD_TESTING=OFF --merge-install |
| 106 | + |
| 107 | +echo |
| 108 | +echo -e "\033[32m============================================================\033[0m" |
| 109 | +echo -e "\033[32mROS-Gazebo Framework Installation completed. Awesome! 🤘🚀 \033[0m" |
| 110 | +echo -e "Following command will set-up ROS-Gazebo environment variables to run it" |
| 111 | +echo -e "\033[95msource /opt/ros/jazzy/setup.bash\033[0m" |
| 112 | +echo -e "\033[95msource /opt/gazebo/install/setup.bash\033[0m" |
| 113 | +echo -e "\033[95mexport PYTHONPATH=\$PYTHONPATH:/opt/gazebo/install/lib/python\033[0m" |
| 114 | +echo -e "You may check ROS, and Gazebo version installed with \033[33mprintenv ROS_DISTRO\033[0m and \033[33mecho \$GZ_VERSION\033[0m" |
| 115 | +echo |
0 commit comments