Windows Operating System
- ROS for Windows requires 64-bit Windows 10 Desktop or Windows 10 IoT Enterprise.
- Please ensure that you have Powershell installed and in the system path.
- Exclude c:\opt (and later your workspace folder) from real-time virus Scanners, as they can interfere with install and development.
Reserve space for the installation
- Clean and back up any existing data under c:\opt before proceeding.
- c:\opt is the required install location. Relocation is not currently enabled.
- Please ensure you have 10 GB of free space on the C:\ drive for the installation and development.
Install Visual Studio 2019
Building a ROS project for Windows requires Visual Studio 2019 and the Microsoft Windows 10 SDK.
* [[https://visualstudio.microsoft.com/vs/older-downloads/|Download Visual Studio 2019|target=»_blank»]]
* Visual Studio 2019 is required to maintain toolchain compatibility with published binaries.
* Vcpkg is used for managing dependent libraries. It requires that the English language pack be installed.
* Include «Desktop development with C++» workload.
Install Windows Package Manager
Chocolatey is a package manager for Windows. It is used to make it easy to install tools and libraries needed for building and running ROS projects. The following instructions redirect the chocolatey install location into the c:\opt, so that you can clean or move a ROS environment from that one location.
- In the Start Menu, find the «x64 Native Tools Command Prompt for VS 2019» item.
- Right Click, select More then «Run as Administrator»
-
Copy the following command line:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"- Paste it into the command window.
- Approve any prompts
- Once it has completed, close the command prompt to complete the install.
-
Install Git:
- Reopen the Visual Studio Command Window as described above.
-
Please install Git using the command here, even if you have it installed as an application:
-
Close and Reopen the Visual Studio Command Window as described above.
-
Ensure Git is now available in the Visual Studio command window:
Installing ROS 2 Binaries
- From the start menu, look for
x64 Native Tools Command Prompt for VS 2019. - Open the command prompt as administrator.
- Run the following to install
ROS 2 Foxy.
mkdir c:\opt\chocolatey
set ChocolateyInstall=c:\opt\chocolatey
choco source add -n=ros-win -s="https://aka.ms/ros/public" --priority=1
choco upgrade ros-foxy-desktop -y --execution-timeout=0 --pre
You can close the command prompt now.
Now you have ROS 2 ros-foxy-desktop installed.
Open a Developer Command Prompt
- From the start menu, look for
x64 Native Tools Command Prompt for VS 2019. - Run the shortcut as administrator.
- Once the developer command prompt is open, run
:: activate the ROS 2 environment
c:\opt\ros\foxy\x64\setup.bat
:: activate the Gazebo simulation environment
c:\opt\ros\foxy\x64\share\gazebo\setup.bat
set "SDF_PATH=c:\opt\ros\foxy\x64\share\sdformat\1.6"
Now you are in the ROS 2 Developer command prompt.
- Current Package Support:
-
-
All of base ROS2
-
MoveIt2 (full support)
-
Navigation2 (Gazebo, path planning)
-
- Not Yet Supported:
-
-
Realsense
-
RTAB-Map
-
warehouse-ros-sqlite
-
If you need any more packages ported for Windows, talk to Akash!
Environment Setup
Let’s start by installing Chocolatey, which is a package manager for Windows.
In order to install it, you will need to run the commands it says in an administrator powershell.
Then, run the following commands to install all the dependencies.
If you already have Python installed, then don’t run that line.
If you already have cmake installed, please uninstall it and let chocolatey install it.
choco install -y python --version 3.8.3 choco install -y cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' choco install -y vcredist2013 vcredist140 ninja
Then, you need to upgrade pip and then install all the pip packages. Make sure to open a new powershell window. This one
does not have to be an administrator one.
python -m pip install --upgrade pip pip install -U vcstool colcon-common-extensions catkin_pkg cryptography EmPy ifcfg lark-parser lxml ` netifaces numpy opencv-python pyparsing pyyaml setuptools rosdistro pydot PyQt5
Then, you need install MSVC which is Microsoft’s C++ compiler. Download
Visual Studio Community 2022.
Make sure to have Desktop development with C+ checked and no C++ CMake tools are checked.
Now, it’s time to actually install ROS2. Go ahead and run the following commands:
mkdir -p C:/opt/ros/foxy cd C:/opt/ros/foxy explorer .
This should open up a File Explorer window in C:/opt/ros/foxy
You’ll want to download
our prebuilt ROS2.
Then, move the ZIP file to C:/opt/ros/foxy, and extract it. You will need 7-zip to extract it.
In order to extract in the correct folder, right click the 7z file, Go to 7-Zip --> Extract files....
This will open up a window. In the Extract to: field put C:/opt/ros/foxy. That’s it! You have ROS installed.
To properly source ROS2, you’ll want to add the following line to your Powershell profile. You can access the file by running
notepad $PROFILE in a Powershell terminal. This will open the file in Notepad. Add the following line to the end and save:
C:/opt/ros/foxy/x64/local_setup.ps1
That’s all!
Other Useful Setup
Using ROS on Windows is extremely annoying, so I have some recommendations to make it much better. I highly recommend you
do these as well.
First, let’s install a better terminal called Windows Terminal. Open the Microsoft Store and search for Windows Terminal.
Then, just click Get and Install. Now, you can open up Windows Terminal by just typing wt in the start menu.
Windows Terminal allows you to have multiple tabs, better shortcuts, and just looks much cooler.
Next, let’s add some utility functions to our powershell profile to make using ROS much simpler.
Before building any ROS 2 workspace, you need to launch a powershell developer shell. Instead of having to launch a separate
terminal, you can just use this utility function called setupDev to make your current terminal have the same properties.
function setupDev { $dir = (Get-Item .).FullName $vsPath = &(Join-Path ${env:ProgramFiles(x86)} "\Microsoft Visual Studio\Installer\vswhere.exe") -property installationpath Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments -arch=x64 cd $dir }
Another issue is when there are CMake or compiler errors with MSVC, nothing is displayed. This is because error output
is printed out to stdout instead of stderr and colcon doesn’t print it to the console. In order to show it, we need to enable the
console_cohesion event handler.
Also, when building ROS 2 workspaces, using the default build system MSBuild is very slow. Ninja is a much faster build system.
In addition, when using MSBuild, colcon build will always rebuild even if no code was changed. However, in order
to use Ninja, you need to add --cmake-args -G Ninja to every single build command which can get annoying.
function colconBuild { colcon build --event-handlers console_cohesion+ --cmake-args -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo $args }
Now, all that functionality can be used using colconBuild. You can
even add extra flags if you want: colconBuild --packages-skip-build-finished
Verifying ROS2 Works
In order to easily verify everything is installed and working correctly run the following commands and make sure there are no errors:
In one terminal run ros2 run demo_nodes_cpp talker and in another terminal run ros2 run demo_nodes_cpp listener.
If there are no errors while these run, that’s great and means that C++ nodes work for ROS2 on your machine!
Next, in one terminal run ros2 run demo_nodes_py talker and in another terminal run ros2 run demo_nodes_py listener.
If there are no errors while these run, that’s great and means that python nodes work for ROS2 on your machine!
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Sign up
Appearance settings
Congratulations on taking the first step into the fascinating realm of robotics!
In this tutorial, I will walk you through the in-depth process to install Ubuntu 22.04 with ROS 2 on a Windows 10/11 system using the free Oracle VirtualBox software.
Pre Requisites
Make sure you satisfy the below prerequisites before installing Ubuntu 22.04 Virtual Machine and ROS 2 Humble on your Windows system.
- A computer running Windows 10 or 11. This guide uses Windows 10 64-bit.
Note: VirtualBox should work fine on any recent version of Windows 10 or 11. - Ubuntu: Desktop 22.04 ISO Image
- Oracle VirtualBox 7.1 software
- Minimum 50 GB of Storage memory
- Minimum of 8 GB of RAM
Let’s dive right into the process to set up Ubuntu 22.04 Virtual machine to start working with ROS 2.
Download Ubuntu 22.04 ISO Image
- This section will walk you through the process of downloading and installing the latest LTS version of the Ubuntu distribution of Linux, i.e.,
Ubuntu 22.04 Jammy Jellyfish. - Go to Ubuntu 22.04 Download Page and Download the 64-bit PC (AMD64) desktop image. A
.isodesktop image will start downloading.NOTE : Windows 10/11 systems are based on the
AMD64/Intel-64architecture. Make sure you use theAMDimage for a Windows 10/11 system and not anARMv8image. This step might take time depending on your internet speed.
Download and Install VirtualBox
- In this section, you will use the Oracle VirtualBox software. VirtualBox is a free general-purpose virtualizer available across Linux, Mac OS, and Windows.
- Go to the VirtualBox Downloads page Oracle VM VirtualBox Downloads page and click on the Windows hosts link to download the VirtualBox software. It will download a “.exe” installer file into your Downloads folder.
- Locate and double-click the VirtualBox installer file from the
Downloadsfolder in your File Explorer and it will launch the VirtualBox 7.0.8 Setup wizard. - Click Next on the welcome screen in the Setup Wizard to begin the process.
-
On the Custom Setup screen, you can leave the default selections for now so that the installer can set up Wizard to install the features. You can change the installation location by clicking on Browse or else leave the default location. Click Next when ready to continue.
-
The next screen will show a Warning about the network interfaces. The Setup Wizard will install a virtual network adapter that may reset and temporarily disconnect the network connection. Click on Yes to process the installation.
-
The next screen will ask you to confirm the installation. Click on Install to begin the installation of VirtualBox 7.0.8. The installation process will begin and it might take several minutes.
-
Once the installation is done, click on the Finish button to exit the Setup Wizard.
-
Launch the VirtualBox Manager from the
StartMenu.
Creating Virtual Machine
Once the VirtualBox Software is installed properly, you can begin creating your Virtual Machine.
-
Click the New button from the top Menu on the VirtualBox Manager window. This will open the Create Virtual Machine wizard which will let you create and configure your new Virtual Machine with the desired settings.
-
On the Virtual Machine Name and Operating System section, fill in the name, Folder (location to store the Virtual machine files), and select the
Ubuntu 22.04 ISO Image(downloaded in the previous section) in the ISO Image option.
Click on the Next button to process. - On the Unattended Guest OS Install Setup section, you need to enter your
usernameandpasswordin addition to your machine name so that it can be configured automatically during the first boot. -
Also, check the Guest Additions box to install the default Guest Additions ISO that is downloaded as part of VirtualBox.
-
In the next Hardware section, specify how much of your host machine’s RAM and processors the virtual machine can use. Change the slider position to allocate the correct values.
NOTE: For using ROS 2 application, it is recommended to use a minimum of8 GB RAMand at least6 CPUs. -
Next in the Virtual Hard Disk section, specify the size of the hard disk for the virtual machine. For ROS 2, it is recommended around
50 GBas a minimum. -
Click Next to continue and view a summary of your virtual machine setting. After this click Finish to initialize the machine.
-
You will see a message saying
Powering VM up …in the VirtualBox manager and a new desktop Window will appear for your Ubuntu 22.04 Virtual machine’s first boot. -
On the first boot, it will begin the unattended installation.
-
Once the installation completes, the machine will automatically reboot to complete the installation.
-
Finally, you will be greeted with the Ubuntu log-in screen where you can enter your
usernameandpassworddefined during the previous setup.
Install ROS 2 Humble Hawksbill
Hang in there!!
You are one step away from becoming a ROS 2 developer with your Ubuntu 22.04 VirtualBox Machine setup.
To install the latest LTS version of ROS 2, i.e., Humble Hawksbill, follow the steps here.
Voila!! I hope you have ROS 2 Humble Running on Ubuntu 22.04 inside a Virtual Machine on Windows Laptop.
If you liked the article, please buy me a ☕️ coffee
Currently, I am reading The Light We Carry by Michelle Obama.
References:
- https://ubuntu.com/tutorials/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox
-
How to Install Ubuntu 23.04 on VirtualBox on Windows 10 & 11
-
- https://docs.ros.org/en/humble/index.html
Getting Started ROS2
We will proceed with
Humble ROS release (opens in a new tab) as it is the
most stable and recent LTS. This page explains the installation.
In summary:
- Option 1: For the best learning and development experience, it is highly
recommended to install Ubuntu 22.04. Ubuntu 20.04 is also okay. But you might
have difficulties during the last part of this tutorial. - Option 2: If you need to learn ROS on Windows, opt for WSL (Windows Subsystem
for Linux) and install Ubuntu version instead of the
Windows native version (opens in a new tab). - Option 3: For those who don’t have either of the above options, I have created
a Docker image.
Installation options
Option 1: Ubuntu 22.04 (best case)
If you can use Ubuntu 22.04, it caters
Humble ROS release (opens in a new tab) in its source
list. You can install ROS locally. All you need is just to follow
the instructions (opens in a new tab)
by copy-and-paste. Install full desktop packages by
sudo apt install ros-humble-desktop. It can take a couple of minutes.
For Ubuntu 20.04 users
You cannot install locally Humble version in this case. Instead, you have to use
the earlier version Foxy. Although as of now July 2023, choosing Humble your
target distribution is the best option, Foxy is enough for learning the basics
of ROS2. Visit
here (opens in a new tab)
and follow the instructions one by one.
Option 2: WSL2 (Windows users)
To learn ROS2 on a Windows machine, setting up a Linux environment can
significantly enhance the learning experience, rather than following Windows
native installation of ROS. One efficient way to achieve this is by utilizing
Windows Subsystem for Linux (WSL2).
Bring Ubuntu to Windows
Firstly, you need to install
WSL2 (opens in a new tab) on your Windows
system to have a virtual environment for Ubuntu 22.04.
Follow the steps in
this video tutorial (opens in a new tab) to get
WSL2 up and running. After opening ubuntu terminal, please make sure
lsb_release -a outputs 22.04 version.
If your default Ubuntu distribution is not 22.04 (e.g., 20.04), visit the
Microsoft Store and install Ubuntu
22.04 (opens in a new tab)
instead.
Enable GUIs (Only for Windows 10 Users)
If you are a Windows 11 user, you can access the GUIs running on Ubuntu
terminal, out-of-box. Run xmessage --center hello and a small window will
popup. However, if you are running Ubuntu on WSL 2 of Windows 10, you have to do
additional setup. Follow
the tutorial video (opens in a new tab) for this
process:
Same Process with Ubuntu on WSL
Now you can use Ubuntu on Windows. Overall, the remainder is the same as what
this page explains.
Option 3. Docker
- First of all, if you have not installed docker, follow the installation guide
here (opens in a new tab). Windows users can
install Docker by following
this link (opens in a new tab). - Pull the prepared
image (opens in a new tab)
byThis image is Ubuntu 22.04 and contained basic features like
bash-completionto resemble a clean Ubuntu installation as best as
possible.
Starting a Simple ROS program
We run a demo program in the package
turtlesim (opens in a new tab).
During part1, this package will help us to understand the basics of ROS2.
To be checked
Installation directory /opt/ros/humble
The installations of core and shipped packages are installed in
/opt/ros/humble (if you installed foxy, /opt/ros/foxy). later if you want to
remove ROS2, delete the directory.
Sourcing setup.bash
To utilize the convenient commands provided by ROS in terminals, we need to
configure the opened terminal to recognize the set of ROS commands by sourcing
the file /opt/ros/humble/setup.bash into your terminal. Open ~/.bashrc and
make sure the line source /opt/ros/humble/setup.bash is written.
After completing these steps, you will be able to utilize tab-completion. When
you type ros2 and press the tab button on a terminal, the following options will
appear:
Install demo package if not installed
Run sudo apt-get install ros-humble-turtlesim in case it’s not installed.
Run demo program turtlesim_node
Open a terminal (calling Terming A) and run the command:
This will open a GUI window. In the center, you will find a turtle.
In another terminal (Terminal B)
And in Terminal B, try pressing arrow-keys to move the turtle.
What’s next?
Congratulation 👍 You’re all set. From the next page, we will have a fun while
learning the fundamentals of ROS with the adorable turtle and your terminal.
