Now any ROS developer worth his salt would recommend you to start developing ROS on Ubuntu. If you are in the 2% who use Ubuntu or any other Linux based OS then that advice is spot on, and you will probably be up and running in a couple of hours. But what if you use Windows like 75% of the people out there?
You would stumble at every step until that nightmarish learning curve gives you sleepless nights, and jitters whenever you hear the word ‘terminal’. Now, I am not saying that you shouldn’t give Ubuntu a shot if you have only ever worked on Windows. Ubuntu is a great OS! I have been using it for more than 10 years now as my daily driver.
But you just want to learn ROS, so why bother with learning to navigate a whole new OS for it? Microsoft has got your back (and probably data) on this. The big M is fully onboard the ROS game and now sits in the core committee that decides the future of ROS. They have done enough porting and development in the past few years that it is now possible to enjoy ROS in the comfort of your Windows.
So without any further yip-yap lets start our ROS journey on Windows 10. Here is what you need to do:
Step 1: Make sure that you are using either a 64 bit version of Windows 10 Desktop or Windows IoT Enterprise. If not, learn Ubuntu.
Step 2: Install Windows PowerShell using this article as a reference.
Step 3: Add the ‘C:\opt’ location, where we will be installing ROS, as an exception on your antivirus software. That thing will probably interfere with the installation and use.
Step 4: You will need 10 GB of space on your C: drive, and you will need to free up the ‘C:\opt’ location, if its being currently used. There is no way to install ROS anywhere else at the time of writing of this article.
Step 5: Download Visual Studio 2019 from here and install it with the following configurations:
– Select the “Desktop Development with C++” option in the workload section.
– Select “Windows 10 SDK (10.0.19041.0)” in the individual components section.
– Select the “English” language pack – there is no support for other languages in ROS yet.
This might take some time, so grab a glass of water because you want to be healthy.
Step 6: Click on start menu and search for “x64 Native Tools Command Prompt for VS 2019”, right click on it and open it as administration.
Step 6: A package manager makes it much easier to install and maintain the various ROS libraries and tools, in Ubuntu ‘apt’ takes care of it, on Windows 10 it will be ‘Chocolatey’. Paste the following into the command window you just opened.
@"%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"
Hit enter on this long ass command and watch it install chocolatey, accept any prompts that come up. Now close the command window and relaunch it, same as before.
Step 7: Type/copy-paste the following into the new command window to install git.
choco upgrade git -y
Use the following command to test if git is installed correctly,
Close the window again and reopen it the same way.
Step 8: Now comes a choice you must make, ROS 1 or ROS 2. Check out this article for finding out what’s the difference between the two.
If ROS 1 is your choice, then enter the following command into the command window.
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-noetic-desktop_full -y --execution-timeout=0
If it’s ROS 2 that you chose, enter the following.
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
It will take some time, go take a break and watch the leaves grow on a tree near you.
Step 7: Each time you open a new command window, you will to run a script to get all the ROS commands working. It is a bit tedious to do that every time, so we will create a shortcut to do that for us every time we open a new command window.
Right click on your desktop and select New > Shortcut
Depending on the Visual Studio version you have installed, type the following in that opened window.
C:\Windows\System32\cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64&& set ChocolateyInstall=c:\opt\chocolatey&& c:\opt\ros\noetic\x64\setup.bat
C:\Windows\System32\cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64&& set ChocolateyInstall=c:\opt\chocolatey&& c:\opt\ros\noetic\x64\setup.bat
C:\Windows\System32\cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64&& set ChocolateyInstall=c:\opt\chocolatey&& c:\opt\ros\noetic\x64\setup.bat
And then name the shortcut as “ROS” or whatever your heart desires, it will open the command window anyway.
Now we will need to make the shortcut always open as an administrator. Right click on shortcut and navigate to properties, choose the advanced… option and check the box for “Run as administrator”. Hit OK and then Apply the changes.
As a final test, lets run ROS . In the opened window, type
and hit enter, you should see the following happen.
Congratulations! ROS is now up and running on your Windows 10!