ROS2入門教程-windows安裝ROS2
ROS2入門教程-windows安裝ROS2
說明:
- 介紹怎么在視窗系統下安裝ROS2
系統要求
- 建議使用win 10系統
安裝ROS2的前提准備
-
1.安裝的巧克力
-
Chocolatey的相關下載鏈接:https://chocolatey.org/
-
2.通過Chocolatey安裝Python
-
打開命令提示符,然后鍵入下面的命令:
choco install -y python
-
3.安裝OpenSSL
-
從下面提供的鏈接下載OpenSSL安裝程序。請下載Win64 OpenSSL v1.0.2,不要下載Win32或者Light版本。
-
OpenSSL的相關鏈接:https://slproweb.com/products/Win32OpenSSL.html
-
使用默認參數運行安裝程序。然后,定義環境變量(下面的命令假定使用了默認安裝目錄):
setx -m OPENSSL_CONF C:\OpenSSL-Win64\bin\openssl.cfg
#Add C:\OpenSSL-Win64\bin\ to your PATH
-
4.安裝Visual Studio Community 2015
-
Visual Studio Community 2015的相關下載鏈接:https://www.visualstudio.com/vs/older-downloads/
-
確保安裝到所需的功能。
-
5.安裝DDS供應商
-
二進制軟件包將eProsima FastRTPS和Adlink OpenSplice作為中間件整合在一起。要使用其他DDSvendor,則需要從源代碼開始構建。
-
eProsima FastRTPS&Boost(僅適用於beta-1及更早版本)
-
Adlink OpenSplice
-
如果想要使用OpenSplice,你需要下載最新版本(最低要求版本為6.7.170912)
-
OpenSplice的相關下載鏈接:https://github.com/ADLINK-IST/opensplice/releases/tag/OSPL_V6_7_171127OSS_RELEASE
-
-
6.安裝OpenCV
-
OpenCV的相關下載鏈接:https://github.com/ros2/ros2/releases/download/release-beta2/opencv-2.4.13.2-vc14.VS2015.zip
-
PATH環境變量設置:
c:\dev\opencv-2.4.13.2-vc14.VS2015\x64\vc14\bin
-
7.安裝依賴項
-
請從這個GitHub存儲庫下載這些軟件包。
-
asio.1.10.6.nupkg
-
本征3.3.3.nupkg
-
TinyXML的-usestl.2.6.2.nupkg
-
tinyxml2.4.1.0.nupkg
-
-
下載完成后,執行以下命令:
choco install -y -s <PATH\TO\DOWNLOADS\> asio eigen tinyxml-usestl tinyxml2
# <PATH\TO\DOWNLOADS>為已下載軟件包的文件夾的對應路徑
- 您還必須安裝
pip
一個python包,yaml
:
python -m pip install -U pyyaml setuptools
下載ROS2
-
ROS2的相關下載鏈接:https://github.com/ros2/ros2/releases
-
下載適用於Windows的最新軟件包,例如
ros2-package-windows-AMD64.zip
。- 注意:可能有多個二進制下載選項可能導致文件名不同。
-
解壓縮zip文件(我們假設
C:\dev\ros2
)。
設置ROS2的環境
- 執行以下命令以及source RO2的配置文件來設置工作空間
call C:\dev\ros2\local_setup.bat
- 如果您下載了具有OpenSplice支持的版本並希望將其用作中間件,則必須另外獲取OpenSplice安裝文件。只有這樣
after
你才能獲得ROS 2:
call "C:\opensplice67\HDE\x86_64.win64\release.bat"
試試一些例子
- 打開一個終端,執行以下命令:
ros2 run demo_nodes_cpp talker
- 打開一個新終端,執行以下命令:
ros2 run demo_nodes_py listener
- 運行結果圖如下:
排除故障
-
如果不能運行例子且出現缺少dll的報錯,請檢查前面安裝的外部依賴的所有的庫,例如:OpenCV的
PATH
環境變量是否設置正確 -
如果前面在設置時忘記執行
call C:\dev\ros2\local_setup.bat
命令,則可能無法運行演示
參考鏈接
- https://github.com/ros2/ros2/wiki/Windows-Install-Binary
- http://blog.csdn.net/weixin_38294178/article/details/78844744
Installing ROS 2 on Windows¶
Table of Contents
This page explains how to install ROS 2 on Windows from a pre-built binary package.
System requirements¶
As of beta-2 only Windows 10 is supported.
Installing prerequisites¶
Install Chocolatey¶
Chocolatey is a package manager for Windows, install it by following their installation instructions:
You’ll use Chocolatey to install some other developer tools.
Install Python¶
Open a Command Prompt and type the following to install Python via Chocolatey:
> choco install -y python
Install OpenSSL¶
Download an OpenSSL installer from this page. Scroll to the bottom of the page and download Win64 OpenSSL v1.0.2. Don’t download the Win32 or Light versions.
Run the installer with default parameters. The following commands assume you used the default installation directory:
-
setx -m OPENSSL_CONF C:\OpenSSL-Win64\bin\openssl.cfg
You will need to append the OpenSSL-Win64 bin folder to your PATH. You can do this by clicking the Windows icon, typing “Environment Variables”, then clicking on “Edit the system environment variables”. In the resulting dialog, click “Environment Variables”, then click “Path” on the bottom pane, finally click “Edit” and add the path below.
-
C:\OpenSSL-Win64\bin\
Install Visual Studio¶
Install Visual Studio 2019.
If you already have a paid version of Visual Studio 2019 (Professional, Enterprise), skip this step.
Microsoft provides a free of charge version of Visual Studio 2019, named Community, which can be used to build applications that use ROS 2:
Make sure that the Visual C++ features are installed.
An easy way to make sure they’re installed is to select the Desktop development with C++
workflow during the install.
Make sure that no C++ CMake tools are installed by unselecting them in the list of components to be installed.
Install additional DDS implementations (optional)¶
ROS 2 builds on top of DDS. It is compatible with multiple DDS or RTPS (the DDS wire protocol) vendors.
The package you downloaded has been built with optional support for multiple vendors: eProsima FastRTPS, Adlink OpenSplice, and RTI Connext as the middleware options. Run-time support for eProsima’s Fast RTPS is included bundled by default. If you would like to use one of the other vendors you will need to install their software separately.
Adlink OpenSplice¶
If you want to use OpenSplice, you will need to download the latest supported version. For ROS 2 Dashing version 6.9.190403OSS-HDE-x86_64.win-vs2017 or later is required.
After unpacking, set the OSPL_HOME
environment variable so that it points to the directory that contains the release.bat
script.
RTI Connext¶
To use RTI Connext DDS there are options available for university, purchase or evaluation
After installing, run RTI launcher and point it to your license file.
Set the NDDSHOME
environment variable:
set "NDDSHOME=C:\Program Files\rti_connext_dds-5.3.1"
If you want to install the Connext DDS-Security plugins please refer to this page.
Install OpenCV¶
Some of the examples require OpenCV to be installed.
You can download a precompiled version of OpenCV 3.4.6 from https://github.com/ros2/ros2/releases/download/opencv-archives/opencv-3.4.6-vc16.VS2019.zip .
Assuming you unpacked it to C:\opencv
, type the following on a Command Prompt (requires Admin privileges):
setx -m OpenCV_DIR C:\opencv
Since you are using a precompiled ROS version, we have to tell it where to find the OpenCV libraries. You have to extend the PATH
variable to C:\opencv\x64\vc16\bin
.
Install dependencies¶
There are a few dependencies not available in the Chocolatey package database. In order to ease the manual installation process, we provide the necessary Chocolatey packages.
As some chocolatey packages rely on it, we start by installing CMake
> choco install -y cmake
You will need to append the CMake bin folder C:\Program Files\CMake\bin
to your PATH.
Please download these packages from this GitHub repository.
-
asio.1.12.1.nupkg
-
eigen-3.3.4.nupkg
-
tinyxml-usestl.2.6.2.nupkg
-
tinyxml2.6.0.0.nupkg
-
log4cxx.0.10.0.nupkg
Once these packages are downloaded, open an administrative shell and execute the following command:
> choco install -y -s <PATH\TO\DOWNLOADS\> asio eigen tinyxml-usestl tinyxml2 log4cxx
Please replace <PATH\TO\DOWNLOADS>
with the folder you downloaded the packages to.
You must also install some python dependencies for command-line tools:
python -m pip install -U catkin_pkg empy lark-parser lxml numpy opencv-python pyparsing pyyaml setuptools
RQt dependencies¶
python -m pip install -U pydot PyQt5
Downloading ROS 2¶
-
Go the releases page: https://github.com/ros2/ros2/releases
-
Download the latest package for Windows, e.g.,
ros2-dashing-*-windows-AMD64.zip
.
Note
There may be more than one binary download option which might cause the file name to differ.
Note
To download the ROS 2 debug libraries you’ll need to download ros2-dashing-*-windows-debug-AMD64.zip
-
Unpack the zip file somewhere (we’ll assume
C:\dev\ros2
).
Set up the ROS 2 environment¶
Start a command shell and source the ROS 2 setup file to set up the workspace:
> call C:\dev\ros2\local_setup.bat
It is normal that the previous command, if nothing else went wrong, outputs “The system cannot find the path specified.” exactly once.
Try some examples¶
In a command shell, set up the ROS 2 environment as described above and then run a talker
:
> ros2 run demo_nodes_cpp talker
Start another command shell and run a listener
:
> ros2 run demo_nodes_py listener
You should see the talker
saying that it’s Publishing
messages and the listener
saying I heard
those messages. Hooray!
If you have installed support for an optional vendor, see this page for details on how to use that vendor.
Troubleshooting¶
-
If at one point your example would not start because of missing dll’s, please verify that all libraries from external dependencies such as OpenCV are located inside your
PATH
variable. -
If you forget to call the
local_setup.bat
file from your terminal, the demo programs will most likely crash immediately. -
If you see an error related with FastRTPS failing to be loaded, see troubleshooting section in development install instructions.
Build your own packages¶
If you would like to build your own packages, refer to the tutorial "Using Colcon to build packages".