Installing WSL and ROS2
@ ヨハネス · Wednesday, Jul 15, 2020 · 5 minute read · Update at Feb 3, 2021

Let’s setup and use ROS2 in the Windows subsystem Linux


I switched back to windows because the integration of WSL gives me the best of the 2 worlds.

But can it run ROS, too?

In this article, we quickly go over setting up a comfortable WSL and than continue to install ROS2.

Whatever, take me to the TR:DL already

Setting up WSL

Currently I am on a Surface GO and it doesn’t support WSL2 yet, I hope I can convert the subsystem easily later…

After installing ubuntu 20.04 lts we can start start its shell, which is really ugly. So first we are going to change that by installing oh-my-zsh and a theme.

sudo apt update && sudo apt upgrade -y
sudo apt install zsh terminator fonts-powerline -y
# and install oh-my-zsh
sh -c "$(curl -fsSL"
# and powerlevel 10k theme
git clone --depth=1 ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

In the snippet before we installed terminator for a better shell experience, to actually use it we need to install a x11 server on the windows side. I am using VcXsrv. It’s important to note that it requests a very open firewall rule, but that can be changed afterwards to only allow local host connections.

To use it, configure it in a way to allow multiple windows without shutting down after client disconnects. For now, a windows shortcut defining parameters will do the trick.

"C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto

and give it a test run by starting it in the wsl.

DISPLAY=:0 terminator &

next we have can apply some customizations in the .zshrc file. For example, I don’t really need the git plugin, but I like the ubuntu and lxc one. Granted, lxc is not available in WSL, so I will leave it out here. Just append this to the end of the .zshrc

# this gets sourced earlier, too. consider commenting it out for faster terminator start
source $ZSH/

# set better dir colors if you don't want your eyes to bleed when you venture into the windows side
if [ -f ~/.dir_colors ]; then
  eval `dircolors ~/.dir_colors`
# switch to home directory on start, because default behavior is annoying
if [ -t 1 ]; then
  cd ~

Something else I found useful was creating some simlinks to the windows file system located under /mnt/c. I am pointing them to my home folder and my repository folder. And we download the dir_colors file from this server.

ln -s /mnt/c/Users/jsvoe/ winhome
ln -s /mnt/c/Users/jsvoe/repos repos
ln -s /mnt/c/Users/jsvoe/OneDrive onedrive
curl -O
mv dir_colors.txt .dir_colors
# this will also trigger the setup wizard for powerlevel zshell theme
source .zshrc

[Further customization of the powerlevel context is also readily available.}( Interesting is, on local host as the standard user, the context (user@home) is hidden by default. But there is an option to always show it.

Also this is a good moment to setup some ssh credentials, just copy them from the Windows filesystem using the Linux shell.

cp -r winhome/Download/ssh ~/.ssh
chmod 600 .ssh/*
chmod 755 .ssh

realtime clock not accessible and gpg key installation failing

At the time of installation there seems to be a bug that prevents the wsl environment to function correctly. This snippet fixed it. This is supposedly fixed in wsl2 with ubuntu 20.04. But I can’t access it, so whatever. Time to install a random libc instead.

sudo add-apt-repository ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1 -y --allow-downgrades
sudo apt-mark hold libc6

Setting up VcXsrv autostart & terminal taskbar button

The next bit is to make the experience of starting up the whole thing a lot more comfortable than manually starting things after a reboot or seeing that shitty default shell again. For that we will put the X11-Server in autostart and add a little VB Script to be executed by a button on the taskbar. Unfortunately no keyboard shortcut to open the terminal, but that could be done with something like autohotkey.

  • First we need to create the VBS script file somewhere with this content. I called ith start_terminator.vbs and put it in my onedrive, to reuse on other machines.
args = "-c" & " -l " & """DISPLAY=:0 terminator"""
WScript.CreateObject("Shell.Application").ShellExecute "bash", args, "", "open", 0
  • The second step is to create a windows shortcut pointing at that script file with a nice icon.
C:\Windows\System32\wscript.exe %USERPROFILE%\OneDrive\MyDocs\misc\scripts\start_terminator.vbs

Terminator shortcut

  • The final step is to add a shortcut to the windows autostart folder, which is quite hidden these days.
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
"C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto

X11-Server autostart shortcut

Installing ROS2 Foxy Fitzroy

Foxy came out last month and will be supported until 2023. It seems like a good choice to learn and convert code to. For the installation I will just be following the official instructions.

sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s | sudo apt-key add -
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'

and install the software and some helper.

sudo apt update && sudo apt install ros-foxy-desktop python3-argcomplete

until here there was no problem really, but it’s starting now. I could run example nodes and even rqt graph after fixing the qt library.

sudo strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/

however, a network connection wasn’t established between any of the nodes. Even wen starting them in the same terminal using a launch file. I read that this is even worse for WSL2, however there are some workarounds. Mind you, Poeple got ROS1 running in WSL1, but I guess I will just run it on my home server instead.

Than I have to add it’s IP to the Firewall to reach the windows x11 Server, but that’s no issue.


Aside from setting up WSL, it was a huge waste of time.

Social Links