The ultimate guide to setting up your ROS 2 development environment with awesome simulations!
This repository will help you:
- Dual Boot your System.
- Install ROS 2 quickly and painlessly
- Get access to some cool pre-configured simulations
- Jumpstart your robotics projects
- Ubuntu 22.04 (Jammy)
- At least 4GB RAM (8GB recommended for simulations)
- 50GB+ free disk space
- Stable internet connection
Choose your adventure:
🔹 Better performance (full hardware access)
🔹 Recommended for serious ROS development
Complete Dual Boot Guide
Most of you need to install only LINK this One - 64-bit PC (AMD64) desktop image
🔹 Safer for beginners (no partitioning)
🔹 Easy to delete if something goes wrong
VM Setup Guide
For Mac M1/M2, you need to install only LINK this one - 64-bit ARM (ARMv8/AArch64) server install image
Pro Tip: Dual boot = for real robotics work!
Warning: Backup your data before dual booting!
ROS 2 Humble Hawksbill (Installation Guide):
Installation Steps{just copy and paste each command in terminal [for pasting commands in the terminal, press ctrl+shift+v]}
locale # check for UTF-8
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
locale # verify settingssudo apt install software-properties-common
sudo add-apt-repository universesudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpgecho "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/nullsudo apt update
sudo apt upgrade -y
sudo apt install ros-humble-desktopsudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
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
sudo apt update
sudo apt install gz-harmonicsource /opt/ros/humble/setup.bash
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrcsudo apt update
sudo apt install -y ros-humble-ros-gzharmonicecho "export GZ_VERSION=harmonic" >> ~/.bashrc
source ~/.bashrcsudo apt install python3-colcon-common-extensionsmkdir -p ~/ros2_ws/src
cd ~/ros2_ws
colcon buildecho 'source ~/ros2_ws/install/setup.bash' >> ~/.bashrc
source ~/.bashrcThis guide provides step-by-step instructions to install ROS 2 Humble and Gazebo Harmonic on an ARM-based Ubuntu 22.04 system, including environment setup and optimizations for ARM architecture.
Initial System Setup
# Update system
sudo apt update
sudo apt upgrade -y
# Install required dependencies
sudo apt install -y software-properties-common build-essential cmake git curl wget gnupg lsb-releasesudo 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-8sudo apt install curl gnupg lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
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/nullsudo apt update
sudo apt install -y ros-humble-desktopecho 'source /opt/ros/humble/setup.bash' >> ~/.bashrc
source ~/.bashrcsudo apt install -y ros-dev-tools python3-colcon-common-extensions python3-rosdep python3-pip
sudo rosdep init
rosdep updatesudo curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
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/nullsudo apt update
sudo apt install -y gz-harmonicecho 'export LIBGL_ALWAYS_SOFTWARE=1' >> ~/.bashrc
echo 'export MESA_GL_VERSION_OVERRIDE=3.3' >> ~/.bashrc
echo 'export OGRE_RTT_MODE=Copy' >> ~/.bashrc
source ~/.bashrcsudo apt update
sudo apt install -y ros-humble-ros-gz-bridge ros-humble-ros-gz-sim ros-humble-ros-gz-interfacesmkdir -p ~/ros_gz_ws/src
cd ~/ros_gz_ws/src# Environment variables to optimize compilation on ARM
export ASAN_OPTIONS=detect_leaks=0
export CCACHE_SLOPPINESS=pch_defines,time_macros
export CCACHE_COMPRESS=1
export CCACHE_MAXSIZE=5G
# Build with single thread to avoid memory issues
MAKEFLAGS="-j1" colcon build --symlink-install --packages-select ros_gz_bridge --cmake-args -DCMAKE_CXX_FLAGS="-O1"
# Build other packages
colcon build --symlink-install --packages-skip ros_gz_bridgeecho 'source ~/ros_gz_ws/install/setup.bash' >> ~/.bashrc
source ~/.bashrcsudo apt install python3-colcon-common-extensionsros2 run demo_nodes_cpp talkerros2 run demo_nodes_py listenerThis guide provides step-by-step instructions to install ROS 2 Humble and Gazebo Harmonic on M1/M2/M3 Macs using virtualization.
⚠️ CRITICAL ARCHITECTURE WARNING: ROS 2 Humble requires Ubuntu 22.04 LTS. Do not use Ubuntu 24.04. Furthermore, you must use the ARM64 version of Ubuntu, not the AMD64 desktop version.
- Download UTM: Get the virtual machine software from mac.getutm.app. (https://www.youtube.com/watch?v=nUhQy5PDj2A&t=1129s)
- Download Ubuntu 22.04 ARM Server: Download the
Ubuntu 22.04 LTS ARM64 ServerISO from the alternative architectures page on the official Ubuntu website. - Configure UTM:
- Open UTM and click + -> Virtualize -> Linux.
- Browse and select the Ubuntu 22.04 ARM Server ISO.
- RAM: Allocate at least
4096 MB(8GB recommended). - CPU: Allocate 4 to 8 cores.
- Storage: Allocate at least 64 GB (ROS 2 and Gazebo take up significant space).
- Install Ubuntu Server:
- Boot the VM and follow the standard "Try or Install Ubuntu Server" prompts.
- Troubleshooting Note: If the VM hangs on the reboot log after installation finishes, power off the VM, click the CD/DVD dropdown in the UTM settings, select Clear to remove the ISO, and start it again.
- Install Graphical Interface (GUI):
- Log into the command line and run:
sudo apt update sudo apt install tasksel sudo apt install ubuntu-desktop
- This will take 20-30 minutes. Once complete, run
sudo reboot now.
- Log into the command line and run:
- Enable Retina Resolution & Copy/Paste:
- Log into your new desktop environment, open the terminal, and install the SPICE tools:
sudo apt install spice-vdagent spice-webdavd
- Shut down the VM. In UTM Settings -> Display, check Retina Mode. Start the VM again.
- Log into your new desktop environment, open the terminal, and install the SPICE tools:
Open the terminal in your Ubuntu VM and run the following commands sequentially.
# Update system and install required dependencies
sudo apt update && sudo apt upgrade -y
sudo apt install -y software-properties-common build-essential cmake git curl wget gnupg lsb-release locales
# Set Locale
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
# Add ROS 2 GPG Key and Repository
wget -qO- https://packages.osrfoundation.org/gazebo.gpg | sudo tee /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg > /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
git clone https://github.com/gazebosim/ros_gz.git -b humble
# Install ROS 2 Humble Desktop
sudo apt update
sudo apt install -y ros-humble-desktop
# Setup Environment
echo 'source /opt/ros/humble/setup.bash' >> ~/.bashrc
source ~/.bashrc
# Install Dev Tools & Initialize rosdep
sudo apt install -y ros-dev-tools python3-colcon-common-extensions python3-rosdep python3-pip
sudo rosdep init || true
rosdep update
# Add Gazebo Repository
wget -qO- [https://packages.osrfoundation.org/gazebo.gpg](https://packages.osrfoundation.org/gazebo.gpg) | sudo tee /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg > /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](http://packages.osrfoundation.org/gazebo/ubuntu-stable) $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
# Install Gazebo Harmonic
sudo apt update
sudo apt install -y gz-harmonic
# Optimize VM Graphics for ARM MacBooks
echo 'export LIBGL_ALWAYS_SOFTWARE=1' >> ~/.bashrc
echo 'export MESA_GL_VERSION_OVERRIDE=3.3' >> ~/.bashrc
echo 'export OGRE_RTT_MODE=Copy' >> ~/.bashrc
source ~/.bashrc
# Create the workspace
mkdir -p ~/ros_gz_ws/src
cd ~/ros_gz_ws/src
# Clone the proper humble branch for the integration packages
git clone [https://github.com/gazebosim/ros_gz.git](https://github.com/gazebosim/ros_gz.git) -b humble
cd ~/ros_gz_ws
# CRITICAL: Tell the compiler to target Harmonic instead of Fortress
export GZ_VERSION=harmonic
# Set environment variables to prevent the VM from running out of RAM during compilation
export ASAN_OPTIONS=detect_leaks=0
export CCACHE_SLOPPINESS=pch_defines,time_macros
export CCACHE_COMPRESS=1
export CCACHE_MAXSIZE=5G
# Install ROS dependencies for the workspace
rosdep install -r --from-paths src -i -y --rosdistro humble
# Build the workspace (using a single thread to avoid VM freezing/crashing)
MAKEFLAGS="-j1" colcon build --symlink-install --cmake-args -DCMAKE_CXX_FLAGS="-O1"
# Source the newly built bridge
echo 'source ~/ros_gz_ws/install/setup.bash' >> ~/.bashrc
source ~/.bashrcros2 run demo_nodes_cpp talkerros2 run demo_nodes_py listenerTurtlesim is a lightweight 2D simulator built into ROS 2. It's the easiest way to verify your installation and learn core ROS 2 concepts like nodes, topics, and services.
ros2 run turtlesim turtlesim_noderos2 run turtlesim turtle_teleop_keyUse arrow keys to move the turtle around the window.
ros2 topic pub /turtle1/cmd_vel geometry_msgs/msg/Twist \
"{linear: {x: 2.0}, angular: {z: 1.8}}"#in different terminals
ros2 node list
ros2 topic listYou will learn more about these terms in depth soon.
A built-in Gazebo demo of a two-wheeled differential drive robot. No extra packages needed.
gz sim diff_drive.sdfThis opens a Gazebo Harmonic window with a two-wheeled robot ready to drive.
gz topic -t "/model/vehicle_blue/cmd_vel" -m gz.msgs.Twist -p "linear: {x: 1.0}"gz topic -t "/model/vehicle_blue/cmd_vel" -m gz.msgs.Twist -p "angular: {z: 0.5}"gz topic -t "/model/vehicle_blue/cmd_vel" -m gz.msgs.Twist -p "linear: {x: 1.0}, angular: {z: 0.5}"Note: Make sure to play the simulation by clicking the play button on the bottom left in Gazebo.
gz topic -lNote: On Mac, make sure Gazebo Harmonic is installed before running these commands.