当前位置: 首页 > news >正文

在windows10上安装运行ROS2

ROS2一般都是在Ubuntu上运行开发。现在想尝试在windows上安装。根据官方的指导一步步来。

截止2021年12月,最新版本的ROS2是foxy;官方放出的稳定版是Galactic。看了一下,在安装上这两个版本没有什么太大的不同,不知道使用情况差别如何。下面的安装是foxy,不过做笔记的时候把Galactic的部分拷贝过去了。如果你想用foxy,那本质上不会有什么差别,都是一样的,你直接把下载的ROS2的Galactic换成Foxy就行了。

下面给出的说明是来自原来官方的指导,地址在这里,

Installing ROS 2 on Windows — ROS 2 Documentation: Foxy documentation

Installing ROS 2 on Windows — ROS 2 Documentation: Galactic documentation

我自己在一步步安装的时候,添加了一些中文说明和指导。

安装 chocolatey

1. Choose How to Install Chocolatey:

一般选individual

2. Install Chocolatey for Individual Use:

  1. First, ensure that you are using an administrative shell - you can also install as a non-admin, check out Non-Administrative Installation.

    --------> 以管理员身份打开power shell。

  2. Install with powershell.exe

    📝 NOTE: Please inspect https://community.chocolatey.org/install.ps1 prior to running any of these scripts to ensure safety. We already know it's safe, but you should verify the security and contents of any script from the internet you are not familiar with. All of these scripts download a remote PowerShell script and execute it on your machine. We take security very seriously. Learn more about our security protocols.

    With PowerShell, you must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.

    • Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process.

      --------> 在powershell中运行Get-ExecutionPolicy指令,如果返回的是“Restricted”,那 么就通过“Set-ExecutionPolicy AllSigned”或“Set-ExecutionPolicy Bypass -Scope Process”指令设置

Now run the following command:

--------> 现在,请运行下面的指令(说明:运行该指令后会有一长串的安装信息,后第3,4步指的就是这个操作)

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

  1. Paste the copied text into your shell and press Enter.

  2. Wait a few seconds for the command to complete.

  3. If you don't see any errors, you are ready to use Chocolatey! Type choco or choco -? now, or see Getting Started for usage instructions.

    --------> 现在,输入“choco”或"choco-?"检查是否安装完好。

安装结果如下图所示,


Chocolatey Licensed Install:

Are you also installing a commercial edition of Chocolatey?

Please see Install the Licensed Edition.


Advanced Chocolatey Install:

Are you installing behind a proxy, need a completely offline install, or wanting to install a licenced edition of Chocolatey? Need even more options? Visit our Documentation or take our new Installation Course to help you get up and running with Chocolatey!

Install Python

Open a Command Prompt and type the following to install Python via Chocolatey:

choco install -y python --version 3.8.3

ROS 2 expects the python installation to be available in directory C:\python38. Double check that it is installed there.

Install Visual C++ Redistributables

Open a Command Prompt and type the following to install them via Chocolatey:

choco install -y vcredist2013 vcredist140

Install OpenSSL

Download the Win64 OpenSSL v1.1.1L OpenSSL installer from this page. Scroll to the bottom of the page and download Win64 OpenSSL v1.1.1L. Don’t download the Win32 or Light versions.

Run the installer with default parameters, as the following commands assume you used the default installation directory.

This command sets an environment variable that persists over sessions:

setx -m OPENSSL_CONF "C:\Program Files\OpenSSL-Win64\bin\openssl.cfg"

You will also 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:\Program Files\OpenSSL-Win64\bin\

--------> 整个这一段是说,要到下面的地址下载Win64 OpenSSL v1.1.1L,

Win32/Win64 OpenSSL Installer for Windows - Shining Light Productions

然后安装,再然后设置环境变量

setx -m OPENSSL_CONF "C:\Program Files\OpenSSL-Win64\bin\openssl.cfg"

再设置路径C:\Program Files\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. You can download the installer directly through this link.

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)

If you would like to use another DDS or RTPS vendor besides the default, Eclipse Cyclone DDS, you can find instructions here.

--------> 这个安装是可选项,如果不是使用默认的fast RTPS,就要自己再去安装,

Downloads

输入你的用户名和邮箱后,会出现下载页面,在windows系统中,选择下载eProsima Fast DDS,如下所示,

eProsima Fast DDS

我使用默认的RTPS,所以这一步我是直接跳过的。

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.

--------> 我自己的做法是,下载上面的opencv包“opencv-3.4.6-vc16.VS2019.zip”后,解压到:D:\opencv346vc16vs2019,然后设置路径

setx -m OpenCV_DIR D:\opencv346vc16vs2019

然后,添加路径到环境变量:

D:\opencv346vc16vs2019\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.

--------> 因为本人电脑上早就已经安装好了cmake,所以上面这一步直接跳过。

Please download these packages from this GitHub repository.

  • asio.1.12.1.nupkg

  • bullet.2.89.0.nupkg

  • cunit.2.1.3.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 cunit eigen tinyxml-usestl tinyxml2 log4cxx bullet

-------->我在这个地址:(https://github.com/ros2/choco-packages/releases/tag/2020-02-24)下载了所有的文件包,然后把这些文件放在“D:\ROS2\choco-packages”,执行下面的指令安装

choco install -y -s D:\ROS2\choco-packages asio cunit eigen tinyxml-usestl tinyxml2 log4cxx bullet

Please replace <PATH\TO\DOWNLOADS> with the folder you downloaded the packages to.

You must also install some additional python dependencies:

python -m pip install -U catkin_pkg cryptography empy ifcfg importlib-metadata lark-parser lxml matplotlib netifaces numpy opencv-python PyQt5 pip pillow psutil pycairo pydot pyparsing pyyaml rosdistro setuptools

--------> 安装后面这个python的安装指令时,我碰到了PIP版本的问题,如下,

WARNING: You are using pip version 19.2.3, however version 21.3.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. 因此,我不得不升级安装了一下PIP,

C:\Users\Administrator> python -m pip install --upgrade pip

然后执行上面的那个python指令来安装这些工具

python -m pip install -U catkin_pkg cryptography empy ifcfg importlib-metadata lark-parser lxml matplotlib netifaces numpy opencv-python PyQt5 pip pillow psutil pycairo pydot pyparsing pyyaml rosdistro setuptools

Install Qt5

This section is only required if you are building rviz, but it comes with our default set of sources, so if you don’t know, then assume you are building it.

First get the installer from Qt’s website:

Download Qt | Develop Desktop & Embedded Systems | Qt

Select the Open Source version and then the Qt Online Installer for Windows.

Run the installer and install Qt5.

We recommend you install it to the default location of C:\Qt, but if you choose somewhere else, make sure to update the paths below accordingly. When selecting components to install, the only thing you absolutely need is the appropriate MSVC 64-bit component under the Qt -> Qt 5.15.0 tree. We’re using 5.15.0 as of the writing of this document and that’s what we recommend since that’s all we test on Windows, but later Qt5 versions will probably work too. Be sure to select MSVC 2019 64-bit. After that, the default settings are fine.

Finally, set the Qt5_DIR environment variable in the cmd.exe where you intend to build so that CMake can find it:

set Qt5_DIR=C:\Qt\5.15.0\msvc2019_64 set QT_QPA_PLATFORM_PLUGIN_PATH=C:\Qt\5.15.0\msvc2019_64\plugins\platforms

You could set it permanently with setx -m Qt5_DIR C:\Qt\5.15.0\msvc2019_64 and setx -m QT_QPA_PLATFORM_PLUGIN_PATH C:\Qt\5.15.0\msvc2019_64\plugins\platforms instead, but that requires Administrator.

Note

This path might change based on which MSVC version you’re using or if you installed it to a different directory.

--------> QT5安装这一步直接跳过,需要用到的时候可以回头再安装

RQt dependencies

To run rqt_graph you need to download and install Graphviz. The installer will ask if to add graphviz to PATH, choose to either add it to the current user or all users.

-------->到这个网址(Download | Graphviz)下载想要的graphviz,我直接下载的这个包

https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/2.50.0/windows_10_cmake_Release_graphviz-install-2.50.0-win64.exe

安装过程中会有些乱码,因为我的系统设置成了utf-8-unicode的字体,估计是自动识别中文没能成功所产生的。不过我凭经验安装成功了。关于什么是utf-8请参考这个贴子的最后部分:

Pytorch编译maskRCNN问题:cpp_extension.py:189: UserWarning: Error checking compiler version for cl..._tanmx219的博客-CSDN博客

另一种安装方式在Foxy版本的说明如下,

RQt dependencies

python -m pip install -U pydot PyQt5

To run rqt_graph, you’ll need Graphviz.

choco install graphviz

You will need to append the Graphviz bin folder C:\Program Files (x86)\GraphvizX.XX\bin to your PATH, by navigating to “Edit the system environment variables” as described above.

Downloading ROS 2

  • Go to the releases page

  • Download the latest package for Windows, e.g., ros2-package-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-package-windows-debug-AMD64.zip

  • Unpack the zip file somewhere (we’ll assume C:\dev\ros2_galactic).

--------> 这里,我的解压地址是:F:\dev_ROS\softs_ROS\ros2-foxy

Environment setup

Start a command shell and source the ROS 2 setup file to set up the workspace:

call C:\dev\ros2_galactic\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.

--------> 到这里,可以运行环境设置

call  F:\dev_ROS\softs_ROS\ros2-foxy\local_setup.bat

Try some examples

In a command shell, set up the ROS 2 environment as described above and then run a C++ talker:

call  F:\dev_ROS\softs_ROS\ros2-foxy\local_setup.bat
ros2 run demo_nodes_cpp talker

Start another command shell and run a Python listener:

call  F:\dev_ROS\softs_ROS\ros2-foxy\local_setup.bat
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. This verifies both the C++ and Python APIs are working properly. Hooray!

运行上面这两条指令时候,要注意设置环境local_setup.bat,运行结果如下,

Next steps after installing

Continue with the tutorials and demos to configure your environment, create your own workspace and packages, and learn ROS 2 core concepts.

Using the ROS 1 bridge

The ROS 1 bridge can connect topics from ROS 1 to ROS 2 and vice-versa. See the dedicated documentation on how to build and use the ROS 1 bridge.

Additional RMW implementations (optional)

The default middleware that ROS 2 uses is Cyclone DDS, but the middleware (RMW) can be replaced at runtime. See the guide on how to work with multiple RMWs.

Troubleshooting

Troubleshooting techniques can be found here.

Uninstall

  1. If you installed your workspace with colcon as instructed above, “uninstalling” could be just a matter of opening a new terminal and not sourcing the workspace’s setup file. This way, your environment will behave as though there is no Galactic install on your system.

  2. If you’re also trying to free up space, you can delete the entire workspace directory with:

    rmdir /s /q \ros2_galactic

    PreviousNext

ROS暂时跑起来了,后续要研究的东西很多,windows到底和ubuntu上有什么不同我也不清楚,毕竟大多数都是玩ROS-melodic和ROS-noetic过来的,所以后面还要多花点时间来学习windows上的ROS2。

相关文章:

  • Ubuntu18.04 安装 ros2 foxy
  • VSCode常用操作
  • Ceres-Solver安装与简介
  • SLAM算法VINS-MONO安装运行介绍
  • Protobuf,gmock,gtest在windows10上的编译与安装
  • CMD闪退的问题及报错“点的大小应介于5和72之间”
  • 常用git 指令
  • 常用的anaconda(conda)命令
  • pcl_viewer的使用与viewer窗口编程
  • OpenVINO+Yolov5+Windows10的CPU部署
  • PCD(点云数据)文件格式
  • Labelme在windows下的编译与vscode开发执行
  • Tools_vcpkg包管理工具在VS2019项目开发中的使用
  • Windows通过winscp登陆Ubuntu18.04
  • Ubuntu18.04安装RTL8125/RTL8168等网卡驱动程序
  • [NodeJS] 关于Buffer
  • [译]CSS 居中(Center)方法大合集
  • 【跃迁之路】【477天】刻意练习系列236(2018.05.28)
  • 【跃迁之路】【699天】程序员高效学习方法论探索系列(实验阶段456-2019.1.19)...
  • JavaScript-Array类型
  • JavaSE小实践1:Java爬取斗图网站的所有表情包
  • Java知识点总结(JDBC-连接步骤及CRUD)
  • laravel5.5 视图共享数据
  • Linux Process Manage
  • python docx文档转html页面
  • 初识 beanstalkd
  • 搭建gitbook 和 访问权限认证
  • 给Prometheus造假数据的方法
  • 工作中总结前端开发流程--vue项目
  • 将回调地狱按在地上摩擦的Promise
  • 前端每日实战:70# 视频演示如何用纯 CSS 创作一只徘徊的果冻怪兽
  • 前端面试之CSS3新特性
  • 试着探索高并发下的系统架构面貌
  • 吐槽Javascript系列二:数组中的splice和slice方法
  • 一份游戏开发学习路线
  • 一个项目push到多个远程Git仓库
  • 优秀架构师必须掌握的架构思维
  • 带你开发类似Pokemon Go的AR游戏
  • 好程序员web前端教程分享CSS不同元素margin的计算 ...
  • ​configparser --- 配置文件解析器​
  • # 再次尝试 连接失败_无线WiFi无法连接到网络怎么办【解决方法】
  • #HarmonyOS:Web组件的使用
  • #QT项目实战(天气预报)
  • $redis-setphp_redis Set命令,php操作Redis Set函数介绍
  • (windows2012共享文件夹和防火墙设置
  • (附源码)spring boot智能服药提醒app 毕业设计 102151
  • (附源码)ssm教师工作量核算统计系统 毕业设计 162307
  • (十二)springboot实战——SSE服务推送事件案例实现
  • (一)认识微服务
  • (转)一些感悟
  • (转载)CentOS查看系统信息|CentOS查看命令
  • * CIL library *(* CIL module *) : error LNK2005: _DllMain@12 already defined in mfcs120u.lib(dllmodu
  • ... fatal error LINK1120:1个无法解析的外部命令 的解决办法
  • ... 是什么 ?... 有什么用处?
  • ./configure,make,make install的作用(转)