How to setup ROS Noetic in WSL through Ubuntu 20.04 Focal
Guide for Matteo Matteucci’s Robotics class at PoliMi
Scope: to install the environment needed for the labs without having to deal with Docker or dual booting in Ubuntu.
Target: PCs running Windows 10 or up supporting virtualization.
Basic Installation
First you need to set-up WSL in your machine. From a Windows command line run:
|
|
And fill the username and password as you please.
Now you should get a linux shell, in other case you can launch it from the start menu (simply search Ubuntu, it should also apper in the recently installed section) or from the dropdown menu of the terminal (my suggested method).
Let’s update some packages as a precaution and then continue.
|
|
n.b: If you’re using the internal PoliMi Wifi you may get some errors, simply switching the Wifi from “Public Network” to “Private Network” should fix it. You may have to change it back once you’re done with this tutorial.
Now we start dealing with the core ROS installation. These commands are taken from the Docker repository
|
|
These are the commands for the “base” ROS installation taken from here
|
|
Now finally for the “perception” ROS package
|
|
ℹ️ Note
Basically in the
Dockerfile
shared in class what we just did was simply the first section.(This is not a command!)
dockerfile
1 2
# Start from the ROS Noetic perception image FROM ros:noetic-perception
Now we continue with the other installation commands:
|
|
Update for lesson 7
|
|
You should already be in the home directory but just in case:
|
|
To test it:
In three different tabs execute these commands in this order:
|
|
In case you wanted to run everything in one shot:
After opening the Linux shell:
|
|
Quality of life improvements (you can skip this)
If you want an easier tmux experience with mouse support (like scrolling for output history, click to change pane, etc) and color:
|
|
Cloning
Now your ROS developement environment is fully functioning, so we can just “clone” the distro to be able to interact in a multihost configuration. Write down your Ubuntu username, it’s just the name of the account that we setup in the first step. It also appears before the @
in your shell.
|
|
Now we have to modify the text file into this:
[boot]
systemd=true
[user]
default=UsernameThatIJustToldYouToWriteDOwn
And now just CTRL + O
to save, same name,CTRL + X
to exit.
Now create an empty folder in a place of your liking (possibly in a disk with at least 20Gb)
Open a Powershell terminal in that folder and type:
|
|
Just wait….
If everything went correctly then you can type in the same terminal:
|
|
Wait, again. As soon as the process is complete we can just launch the instance with
|
|
Now we have two identical WSL instances that we can launch from the start menu or from the terminal drop down.
Now, going back to the directory where we exported the backup at the start of this step we have two big files: UbuntuRosBck.tar
and filesystem\ext4.vhdx
⚠️ Warning
Precaution when moving the generated files pt. 1
For
filesystem\ext4.vhdx
: DON’T TOUCH, MOVE OR DELETE IT. It contains all your data.
💡 Tip
Precaution when moving the generated files pt. 2
For
UbuntuRosBck.tar
instead you can either delete it or you can also share it with your friends.
Testing
With this configuration you don’t have to fiddle with Master IPs and such like for Docker. To test it just run like this:
|
|
Sharing is Caring
UbuntuRosBck.tar
basically contain a full linux distro with all the ROS packages already installed. You can transfer it on their PC and then in an empty folder just run:
|
|
Ideally this should just run™
Be mindful to not put anything personal or harmful inside and to give them the password you used in the first step. It’s technically a local VM so it shouldn’t bee too much of a risk from that point of view.
❗ Caution
Just in case it’s not clear:
Your WSL password, not your Windows password!
Also, like for the previous section: please never delete the filesystemprimary\ext4.vhdx
and filesystemsecondary\ext4.vhdx
files but you can delete UbuntuRosBck.tar
file without causing problems.