본문 바로가기

인공지능 로봇 개발

윈도우 10에 ROS Melodic 설치하기

그동안 우분투 환경에서 ROS를 사용하며 많은 불편함이 있었습니다. 익숙하지 않은 우분투에서 IDE를 사용해가며 빌드하는 것이 많이 어려움이 있었습니다. 또한 카카오톡, 게임 등 윈도우에서만 실행 가능한 응용 프로그램을 실행하려면 컴퓨터를 재부팅하는 수고가 많았습니다.

http://wiki.ros.org/Installation/Windows

 

Installation/Windows - ROS Wiki

Under Construction... ROS Electric is EOL, and these instructions for getting it to work on Windows are severely outdated. They are only kept here for historical reasons. Please do not expect these steps to work, or try to follow them. For future Windows s

wiki.ros.org

하지만 MS사에서 ROS를 윈도우에 이식하는 과정을 지원하였고 결국 윈도우 10에서 ROS melodic을 사용할 수 있게 되었습니다. 저는 한번 이를 설치하고 Gazebo를 이용한 드론 시뮬레이션을 해보려고 합니다.

1. Windows Operating System

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

2. 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.

위 두 사항은 뭔가 건드리지 않았다면 상관할 필요가 없습니다. 그리고 C드라이브 용량이 많으면 좋겠습니다.

3. Install Visual Studio 2019

Building a ROS project for Windows requires Visual Studio and the Microsoft SDKs for Windows.

  • Download Visual Studio 2019
  • Include “Desktop development with C++” workload.
  • If you are building WinML, please include the “Universal Windows Platform development” workload.
  • If you already have Visual Studio 2019 installed, you can Modify Installation

비쥬얼 스튜디오를 설치합니다. 별로 어렵지 않았습니다.

https://visualstudio.microsoft.com/ko/downloads/

 

Windows 및 Mac용 Visual Studio 2019 다운로드

Visual Studio Community, Professional 및 Enterprise를 다운로드하세요. 지금 Visual Studio IDE, Code 또는 Mac을 무료로 사용해 보세요.

visualstudio.microsoft.com

여기서 학생이라면 Community 무료 라이센스를 이용하도록 합시다.

단 C++를 사용한 데스크톱 개발을 체크해줍시다. (빨간색 원) 만약 이미 설치되어있다면 Visual Studio Installer로 쉽게 수정이 가능합니다.

설치하면 컴퓨터를 다시 시작해줍니다.

4. Install Windows Package Manager

그 다음 window Package Manager를 설치합니다. 여기서는 Chocolatey 라는 프로그램을 설치하는데 ROS 패키지를 간편하게 설치할 수 있도록 합니다.

왼쪽 밑 윈도우 검색창을 통해 x64 Native Tools Command Prompt for VS 2019를 관리자 권한으로 실행시켜줍니다. 그 후 다음과 같은 코드를 입력합니다.

 

@"%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"

Warning은 뜨지만 크게 문제되지 않으니 무시하도록 합시다. 그리고 x64 Native Tools Command Prompt for VS 2019를 껐다가 다시 켜줍니다. (관리자 권한으로 실행) 그 후 다음 코드를 실행시킵니다.

 

choco upgrade git -y

앞에서 Choco가 잘 깔렸다면 문제없이 git이 잘 설치됩니다. git이 잘 설치되었는지 확인하기 위해 다음 코드를 입력합니다.

 

git --version

그렇다면 다음 결과와 같이 완료된 것을 확인할 수 있습니다. 이제 다시 해당 창을 껐다가 다시 켜줍니다.

5. Binary Package Installation

이제 본격적으로 ROS를 설치합니다.

5.1 ROS Last Known Good (LKG) Build Installation

저희는 ROS의 모든 기능을 사용할 것이므로 desktop_full 패키지를 설치할 것입니다. 또한 가장 최신의 버전을 설치할 것입니다.

mkdir c:\opt\chocolatey
set ChocolateyInstall=c:\opt\chocolatey
choco source add -n=ros-win -s="https://roswin.azurewebsites.net/api/v2" --priority=1
choco upgrade ros-melodic-desktop_full -y --execution-timeout=0

마지막 줄을 입력하면 ROS 설치가 시작되며 1시간 정도 시간이 소요됩니다. 중간중간에 Yes, no를 물어보는데 다 yes라고 해야합니다. 20초동안 선택할 시간을 주는데 그 시간 안에 선택하지 않아도 설치가 되니 굳이 신경쓸 필요는 없습니다.

 

윈도우 프롬프트가 가끔 멈출때가 있으니 그럴 때 엔터 눌러보시면 계속 진행시킬 수 있습니다.

 

중간 중간에 관리자 권한을 요구하여 ‘예’를 눌러줘야합니다. 한 코드씩 차례대로 입력하면 다음과 같이 완료가 됩니다.

중간에 vcpython27 Generic MSI Error로 인해 제대로 설치가 되지 않았지만 창을 껐다가 다시 코드를 입력하여 완료하였습니다. 우여곡절이 많았지만 잘 설치되었으니 다음 단계로 넘어갑니다.

6. Create a ROS Command Window shortcut

다음으로 ROS를 사용하기 위해서 바로가기를 만들어 줍니다. 바로가기 경로는 윈도우 버전에 따라 다르니 잘 선택해줍시다.

탐색기에서 바탕화면에 바로가기를 새로 만들어줍시다. 그 후 경로에 밑에서 자신의 Visual Studio 버전과 맡는 경로를 넣어줍니다. Visual Studio 버전은 학생용으로 다운받았을 경우 Community입니다.

  • If you are using 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\melodic\x64\setup.bat
  • If you are using Professional:
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\melodic\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\melodic\x64\setup.bat

이름은 ROS로 설정하고 관리자 권한으로 실행을 설정해줍니다. ROS 바로가기를 마우스 오른쪽 클릭 후 속성에 들어가 고급을 눌러줍니다.

이제 확인을 누르면 ROS 설치가 완료되었습니다.

7. Windows terminal에서 ROS 사용하기

ROS를 사용하다보면 여러 창에 터미널을 띄워놓고 작업할 일이 많습니다. 이 때 Windows terminal을 사용하여 이를 쉽고 간단하게 관리할 수 있습니다.

Microsoft Store

 

Windows Terminal (Preview) 구매 - Microsoft Store ko-KR

Microsoft Store에서 이 Windows 10용 앱을 다운로드하세요. 스크린샷을 보고, 최신 고객 리뷰를 읽고, Windows Terminal (Preview)에 대한 평점을 비교하세요.

www.microsoft.com

먼저 위 링크를 통해 Windows terminal를 설치합니다.

그 다음 ROS 바로가기를 실행시키고 uuidgen 을 입력합니다. 이 때 나온 값을 복사해놓습니다.

그 다음 시작 메뉴에서 Windows terminal를 찾아 관리자 권한으로 실행합니다.

그 다음 설정에 들어가줍니다.

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

다음 내용을 복사해서 해당 위치에 넣습니다(파란색으로 가려진 코드). XXX로 되어있는 곳에는 복사해둔 코드를 넣습니다.

  • (Optionally) Set this guid as the “defaultProfile”
"alwaysShowTabs" : true,
"copyOnSelect" : false,
"defaultProfile" : "{xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx}",
....

ROS를 기본으로 설정하고 싶다면 defaultprofile도 해당 코드를 넣어주면 됩니다.

이제 ROS를 윈도우에서 구동하기 위한 설정이 모두 끝났습니다.

이후 업데이트가 필요하면 다음과 같은 코드를 입력하여 항상 최신버전을 유지시켜줍니다.

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

마지막으로 설치가 잘 되었는지 확인해보겠습니다.

roslaunch gazebo_ros empty_world.launch

위 코드를 실행시킵니다

다음과 같은 창이 뜨면 성공!

 

다음 스토리에서 더욱 응용해보도록 하겠습니다.