Installing WSL-ROS2 on Windows
Applicable to: Windows 10 or 11 personal (unmanaged) computers
The WSL-ROS2 Simulation Environment¶
To support this course we've created a custom ROS 2 environment which runs on Windows 10 or 11 using the Windows Subsystem for Linux (WSL). We call this "WSL-ROS2" and you can download it via the University of Sheffield Software Download Service (University login required).
Note
When you download WSL-ROS2 from the Software Download Service you will receive an email with installation instructions. We recommend that you follow the instructions provided on this page instead, as this page will be kept more up-to-date throughout the semester.
Prerequisites¶
- Your computer must be running Windows 10 Build 19044 or higher, or Windows 11.
- Update the GPU drivers for your machine.
- Install or update WSL:
- If you don't already have WSL installed on your machine then follow these instructions to install it.
- If you do already have WSL installed on your machine, then follow these instructions to update it.
- Install the Windows Terminal.
- Install Visual Studio Code and the WSL VS Code extension.
- Install the VcXsrv Windows X Server.
Installing¶
- Go to the IT Services Software Downloads page (you'll need to log in with your university MUSE credentials).
-
Scroll down to the bottom, where you should see WSL-ROS listed.
Click on the blue "Request WSL-ROS" button and then wait to receive an email to your university email address.
-
The email will contain a link to download WSL-ROS2 to your machine as a
.zipfile (~2 GB). -
On your computer, create a new folder in the root of your
C:\drive calledWSL-ROS2. -
Save the
.zipfile to this new folder (C:\WSL-ROS2\) -
Launch PowerShell, then run the following commands in order:
-
Identify the zip file:
-
Extract it:
-
Identify the extracted
.tarfile: -
Import this as a WSL distro:
-
-
This may take a couple of minutes. Once it's done, you can verify that it was successful with the following command:
Where
WSL-ROS2should be listed. -
Next (optional), open up the Windows Terminal App, then:
- Go to Settings (Ctrl+,)
- Under
Profilesin the left-hand menu, findWSL-ROS2(or scroll further down and click theAdd a new profilebutton to create it). -
Configure the settings for the
WSL-ROS2profile as shown below:
-
Then, in
Startup(back in the left-hand menu again), underDefault profileselect WSL-ROS2 from the drop-down list.This will ensure that each time you open the Windows Terminal App or you press the New Tab () button a WSL-ROS2 Terminal Instance will be launched by default.
Initial Setup¶
Within a WSL-ROS2 terminal instance, you'll need to run some initial commands to get things set up.
-
First, run the following command to attempt to use native Graphical User Interface (GUI) support (which should work if you followed all the prerequisites above):
-
Then, re-source your
.bashrcfile for this change to take effect: -
Run the following ROS command to see if you can launch the Gazebo GUI:
This should hopefully present you with something like this:
If this doesn't work, then you could try using a third-party X Server (VcXsrv) instead...
Using a Third-Party X Server¶
If you are unable to run GUI apps natively (having completed the steps in the section above), then you could try using a third-party X Server ("VcXsrv") instead. In the prerequisites, you should have already installed VcXsrv.
Note
Only do this if you were unable to launch the robot simulation in the previous section.
- Having installed VcXsrv in the Prerequisites Section...
-
Download this config file for VcXsrv and save it to your desktop as
wsl_ros_config.xlaunch.
-
Double click this to launch VcXsrv with the appropriate settings. An icon should then appear in your notification tray (bottom-right) to indicate that the X Server is running:
-
Launch the WSL-ROS2 environment by launching the Windows Terminal App:
-
In a WSL-ROS2 Terminal Instance, run the following:
-
Re-source your
.bashrcfile for this change to take effect: -
Try running the empty world Gazebo simulation again:
Important
You need to make sure you have the X Server running (by clicking the
wsl_ros_config.xlaunchshortcut) every time you work with WSL-ROS2.
Restarting the WSL Engine¶
If you're having trouble with WSL a restart sometimes helps.
First, close down any WSL-ROS2 terminal windows that you have open (and any connections to WSL-ROS2 in VS Code). Then, launch powershell and shutdown the WSL engine:
Restart the WSL engine by launching a new WSL-ROS2 terminal instance.