Installing ROS noedic under Windows

Keywords: Windows git ROS Visual Studio Code

Installing ROS noedic under Windows

1. System requirements

  • ROS for Windows requires 64 bit Windows 10 Desktop or Windows 10 IoT Enterprise.

  • Make sure you have installed Powershell and are in the system path.

  • Exclude c:\opt (and subsequent workspace folders) from the real-time virus scanner because they interfere with installation and development.

2. Installation space

  • Clean up and back up all existing data under c:\opt before continuing.

  • c:\opt is the required installation location. Relocation is not currently enabled.

  • Make sure you have 10 GB of free space on the C: \ drive for installation and development.

3. Installation

Building ROS projects for Windows requires Visual Studio and Microsoft SDK for Windows.

Note the installation directory Download Visual Studio 2019

  • Vcpkg is used to manage dependent libraries. It requires the English language pack to be installed.

  • Includes the desktop development with C + + workload.

  • In a single component, select Windows 10 SDK (10.0.19041.0).


4. Install Windows package manager

Chocolate is the package manager for Windows. It is used to easily install the tools and libraries needed to build and run ROS projects. The following instructions redirect the chocolate installation location to c:\opt so that you can clean up or move the ROS environment from there.

  • In the start menu, find the "x64 Native Tools Command Prompt for VS 2019" item,

  • Right click, select more, and 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
    • When finished, close the command prompt to complete the installation.
  • Install Git:

    • Reopen the Visual Studio command window as described above.

    • Use the commands here to install Git, even if you have installed it as an application.

      choco upgrade git -y
      
    • After installing git, ensure that Git is now available in the Visual Studio command window.

      git --version
      
    • Close and reopen the Visual Studio command window as described above.

5. Install ROS binary package

To set up ROS for Windows, follow these recommended steps:

5.1 the latest (LKG) compiled installation package of ros1 noetic

First, install the recommended desktop_full yuan package. A meta package is a collection of other packages. The desktop full metapackage refers to many other packages needed to build, run, debug, and visualize robots.
As described above, open the Visual Studio command prompt as an administrator.

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

5.2 ROS2 latest compiled installation package - foxy

To start using ROS 2, you can also follow similar steps to install ROS 2 from the same chocolate source.
For example, if you want to install ROS2 Foxy build, open the ROS command prompt created above. If not, approve the management promotion.

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

5.3 successful test installation

First enter the C: \ opt \ ROS \ noetic \ x64 > directory, run setup.bat to validate the ROS environment, and then run roscore.

6. Create ROS command line window shortcut

To use ROS on Windows, you need to call the ROS setup script in each command window. In order not to forget in the future, it would be helpful to have a ROS shortcut that automatically performs this operation.

  • To create an administrative command line shortcut for Visual Studio:

  • Right click the Windows Explorer folder and select new > shortcut

  • In the shortcut path, copy the highlighted command line from the following options according to the Visual Studio installation above:

    Note the installation path

    • If you use the community:

      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
      
    • If you are using the Professional Edition:

      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
      
    • If you are using enterprise:

      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
      

  • Name the shortcut ROS

  • Set the shortcut as administrator

    • Right click the shortcut and select properties.

    • If the shortcuts tab is not already selected, select.

    • Press the advanced button


-Select the run as administrator button.

-On the advanced properties dialog box, press OK.
-Press OK on the ROS properties shortcut dialog box.

6.1 using a new Windows terminal

Microsoft released a new [open source terminal] for Windows( microsoft/terminal: The new Windows Terminal and the original Windows console host, all in the same place! (github.com) ), which includes many improvements to the built-in command line, including tab and appearance customization. You can Microsoft Store Install it.
Set the terminal for ROS:

  • Find the Windows terminal from the start menu, right-click and select run as administrator

  • Select settings from the drop-down arrow next to the Add Tab (+) button.

  • In the list array of the "profiles" object, add a new block for ROS.

        "profiles" :
        {
            list: 
            [
                ...
                {
                    "commandline" : "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",
                    "guid" : "{xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx}",
                    "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
                    "name" : "ROS Noetic",
                    "startingDirectory" : "c:\\ws"
            },
    

  • From the Visual Studio command window, use the command uuidgen to generate a globally unique identifier (also known as a universal unique identifier)

    • Copy guid (select text and right-click copy)

    • Replace xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with the text copied above

    • After setting, you can open this terminal and run roscore

  • (optional) set this guid to "defaultProfile"

            "alwaysShowTabs" : true,
            "copyOnSelect" : false,
            "defaultProfile" : "{xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx}",
            ....
    

    When starting a new Windows terminal, remember to run as administrator, right-click the Windows terminal and select run as administrator. Before canceling this requirement, you need to implement a function request promoted by Always Run Terminal.
    Alternatively, Ctrl+Shift + clicking the terminal icon in the start menu or taskbar is a convenient shortcut to run as an administrator.

7. Keep updated

If you want to update the ROS installation, use the upgrade feature of chocolate.
Open the ROS command prompt created above and approve the administrative promotion if it is not already open.
Run the following command:

set ChocolateyInstall=c:\opt\chocolatey
choco upgrade all -y --execution-timeout=0

It is recommended to add -- execution timeout = 0 to accommodate choco installation failure caused by slow network.

8. Unloading

Before uninstalling, make sure that no ROS system or program is running on your system.
At the command prompt, run the following command:

  rmdir /s /q c:\opt

Posted by EvilWalrus on Sun, 26 Sep 2021 03:33:53 -0700