ROS Setup for WSL
Step-by-step guides for setting up ROS distributions on Windows Subsystem for Linux.
1. Prerequisites: WSL & Ubuntu
Check if WSL is already installed and view current distributions.
wsl -l -v
Enable WSL via Windows Features (If command is missing):
1. Press the Windows Key, type Turn Windows features on or off, and press Enter.
2. Scroll down and check the box next to Windows Subsystem for Linux.
3. Check the box for Virtual Machine Platform as well (required for WSL 2).
4. Click OK and restart your computer when prompted.
Install the Windows Subsystem for Linux (WSL) core components.
wsl --install --no-distribution
Install the Ubuntu 20.04 distribution (Required for ROS Noetic).
wsl --install -d Ubuntu-20.04
Update current system package lists.
sudo apt update
2. Setup ROS Repositories
Add the official ROS repository to your sources list.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Install curl utility to download keys.
sudo apt install curl -y
Download and add the ROS repository key securely.
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
3. Installation
Update package lists again to include the new ROS repository.
sudo apt update
Install the full ROS Noetic desktop package (includes 2D/3D simulators and tools).
sudo apt install ros-noetic-desktop-full -y
4. Environment Setup
Automatically source the ROS setup script in every new bash terminal.
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
Apply the updated bash profile to your current session.
source ~/.bashrc
5. Verification
Start the ROS Master node. If this runs without errors, your installation is complete!
roscore
1. Prerequisites: WSL & Ubuntu 24.04
Check if WSL is already installed and view current distributions.
wsl -l -v
Enable WSL via Windows Features (If command is missing):
1. Press the Windows Key, type Turn Windows features on or off, and press Enter.
2. Scroll down and check the box next to Windows Subsystem for Linux.
3. Check the box for Virtual Machine Platform as well (required for WSL 2).
4. Click OK and restart your computer when prompted.
Install the Windows Subsystem for Linux (WSL) core components.
wsl --install --no-distribution
Install Ubuntu 24.04 distribution (Noble Numbat). This specific version is strictly required for ROS 2 Jazzy.
wsl --install -d Ubuntu-24.04
Verify your Ubuntu version is exactly 24.04 inside your WSL terminal.
lsb_release -a
2. Set the Locale
Update packages and install the locales package.
sudo apt update && sudo apt install locales -y
Generate the UTF-8 locale.
sudo locale-gen en_US en_US.UTF-8
Apply the UTF-8 locale system-wide.
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
Export the locale to your current session (ROS 2 requires a locale that supports UTF-8).
export LANG=en_US.UTF-8
3. Enable Universe Repository
Install software properties manager.
sudo apt install software-properties-common -y
Enable the Ubuntu Universe repository to access required dependencies.
sudo add-apt-repository universe -y
4. Setup Keys & Repository
Install curl utility.
sudo apt update && sudo apt install curl -y
Download and add the ROS 2 GPG key.
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
Add the ROS 2 Jazzy repository to your sources list.
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
5. Installation
Update apt caches and apply any pending system upgrades.
sudo apt update && sudo apt upgrade -y
Install the full ROS 2 Jazzy desktop setup (includes ROS, RViz, demos, and tutorials).
sudo apt install ros-jazzy-desktop -y
6. Environment Setup
Automatically source the ROS 2 setup script in every new bash terminal.
echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc
Apply the updated bash profile to your current session.
source ~/.bashrc
7. Verification (Talker / Listener)
In your first terminal, start the C++ talker node. It will start publishing 'Hello World' messages.
ros2 run demo_nodes_cpp talker
Open a second, separate WSL terminal and run this to start the Python listener. You should see it successfully receiving the messages.
ros2 run demo_nodes_py listener