November 5, 2024

How to Install Gazebo (Harmonic) in Windows by Using WSL and Ubuntu 24.04 and How to Run Mobile Robot Simulation

In this Robot Operating System 2 (ROS2) and Gazebo simulation tutorial, we explain how to install Gazebo (Harmonic) in Windows by Using Windows Subsystem for Linux (WSL) and Ubuntu 24.04 and how to run a mobile robot simulation in . The idea is to install and use Gazebo in Windows through WSL and Ubuntu 24.04. We need Ubuntu 24.04 since this is the most recent Ubuntu version that can support ROS2 Jazzy Jalisco. Consequently, we need to install the version of Gazebo that can be run together with ROS 2 Jazzy Jalisco and that is Gazebo Harmonic. The YouTube video accompanying this tutorial is given below.

Install Subsystem for Linux -WSL

The first step is to install the Windows Subsystem for Linux (WSL). We can do that by opening PowerShell in administrator mode (click on start, and search for PowerShell and do the right click on PowerShell icon and click on “Run as administrator”) and by typing in the PowerShell prompt:

wsl --install 

This will install WSL. After that you need to reboot the computer. After the system is rebooted you will notice that the default version of Ubuntu is installed. You can verify that by clicking on start, and then search for Ubuntu. By clicking on the Ubuntu icon you will be able to run Ubuntu. However, if you type

lsb_release -a

in the Linux prompt, you will see that the default Ubuntu version is 22.04. However, to run Gazebo Harmonic that will be compatible with ROS2 Jazzy, we will need Ubuntu 24.04

Install Linux Ubuntu 24.04 in WSL

You need Ubuntu 24.04 to run the newest version of ROS2 called Jazzy Jalisco and we will install Gazebo version (Harmonic) that can be used with this version. To install Ubuntu 24.04, open again PowerShell in the administrator mode and type

wsl --list --online

To see the list of all supported Linux distributions that can be run through WSL. The output should look like this

You need to install Ubuntu 24.04. We can do that by typing

wsl --install -d Ubuntu-24.04 

After that, Ubuntu 24.04 will be installed and you will be asked to set your username and password. Then, after that you will be automatically logged in Ubuntu 24.04. Exit this installation by typing exit. Then you will be back in PowerShell. To verify that Ubuntu 24.04 is installed, type this in PowerShell Prompt

wsl -l -v

You should see something like this

This means that Ubuntu 24.04 is installed. Next, we can run Ubuntu 24.04, by clicking on Start and by searching for Ubuntu 24.04. Then click on Ubuntu 24.04, and you should see the standard Ubuntu terminal. Verify the version by typing

lsb_release -a 

The output should look like this

This is another verification that Ubuntu is installed

Install Gazebo Harmonic in WSL and Windows (Ubuntu 24.04)

To install Gazebo, we need to perform the following steps. In the Ubuntu 24.04 WSL terminal type:

sudo apt-get update
sudo apt-get install lsb-release gnupg

Then type

sudo 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/null
sudo apt-get update
sudo apt-get install gz-harmonic

This should install Gazebo Harmonic

Run Gazebo Simulations in Windows through WSL

To run the simulations, we need to type

 gz sim shapes.sdf

This will bring the simulation window shown below and you can play this simulation by pressing the play key

The next step is to verify that we can simulate a mobile robot. We can do that, by typing in the terminal

gz sim 

After this, Gazebo GUI will open, and you can select the mobile robot simulation. For more details see the YouTube tutorial at the beginning of this webpage.