The basics of getting up and running with ROS 2 in Windows
/Development in ROS used to only be able to be done in Linux, with Ubuntu being the only fully supported operating system. With ROS 2, more options have opened up to support ROS development. In this blog post, we’ll discuss how you can get ROS 2 up and running on the Windows.
Why use ROS 2 in Windows?
There are a number of reasons you may wish to pursue ROS development in Windows.
- You or a client are limited in available operating systems
- You want to utilize applications/libraries that are only supported in Windows
- You are much more comfortable with Windows development over Linux development
Why not use ROS 2 in Windows?
While there are good reasons to use ROS in Windows, the reasons against it are substantial:
- ROS 2 packages are still typically developed with Linux in mind, and often don’t build without
- modification
- ROS in Windows is generally less supported and complete than it is in Linux.
- You will have more trouble finding solutions for any problems that come up
- More unexpected issues are likely to pop up than in Linux
- ROS behaviors are not entirely consistent between operating systems
What are my options?
The simplest option to using ROS 2 in Windows is to avoid using Windows as much as possible by using Windows Subsystem for Linux (WSL). WSL operates a Linux kernel on top of the already running Windows kernel, allowing it to execute programs meant for Linux while within Windows. This is much more lightweight than a full virtual machine and allows easy access to files located within your Windows system. Head here (https://learn.microsoft.com/en-us/windows/wsl/install) to get started with WSL.
>A second option is to use a fully pre-built package from the chocolatey package manager. This will streamline the installation process to a few copy-paste commands and greatly reduces the likelihood of errors occurring in the installation process (which can be non-trivial to debug). aka.ms/ros hosts a package for ROS 2 foxy, with instructions available here (https://ms-iot.github.io/ROSOnWindows/GettingStarted/SetupRos2.html)
A final option if you really need a version that is not installable as a full package via chocolatey is to follow the installation instructions for that distro from the ROS 2 docs (https://docs.ros.org/en/humble/Installation/Windows-Install-Binary.html). There are a large number of steps that are far more prone to error, and since Windows is not as well supported, these instructions are more likely to be out of date themselves.
Working with ROS in Windows:
If you choose to use WSL, then congratulations! You don’t have anything new to learn. You have access to a bash shell with all the usual ROS 2 commands you know and love. Simply start your WSL instance and you’re good to go.
If you are truly only using Windows, you will be working within a Powershell or Command Prompt window, which will work with their own commands for you to learn instead of bash. Make sure to call the appropriate setup.ps1 or setup.bat for the terminal you are using, and expect to modify the Cmake for any ROS projects that you are building from source. A few other considerations are listed here (https://docs.ros.org/en/foxy/The-ROS2-Project/Contributing/Windows-Tips-and-Tricks.html)
Conclusion
While it is recommended to stick with Linux for your ROS development, you have options to continue your applications in Windows. There are some extra limitations and difficulties, but once you get past the initial pains, the development process is largely the same.