前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ROS2编程基础课程--中间件

ROS2编程基础课程--中间件

作者头像
zhangrelay
发布2019-09-19 14:13:04
1.1K0
发布2019-09-19 14:13:04
举报

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/ZhangRelay/article/details/100773655

Working with multiple ROS 2 middleware implementations

使用多个ROS 2中间件实现

This page explains the default RMW implementation and how to specify an alternative.

此网页解释了默认的RMW实现以及如何指定备选方案。

Pre-requisites 预备基础

You should have already read the DDS and ROS middleware implementations page.

请先阅读DDS和ROS中间件实现网页

Multiple RMW implementations 多个RMW实现

The current ROS 2 binary releases have built-in support for several RMW implementations out of the box (Fast RTPS, RTI Connext Pro, and ADLink OpenSplice at the time of writing), but only Fast RTPS (the default) works without any additional installation steps, because it is the only one we distribute with our binary packages.

当前的ROS 2二进制版本内置的几个RMW实现版本支持开箱即用(在撰写本文时,如,快速RTPS、RTI Connext Pro和ADLink OpenSplice),但只有Fast RTPS(默认)无需额外安装即可工作步骤,因为它是使用二进制包分发的唯一一个。

Others like OpenSplice or Connext can be enabled by installing additional packages, but without having to rebuild anything or replace any existing packages.

其他像OpenSplice或Connext可以通过安装其他软件包来启用,但无需重建任何内容或替换任何现有软件包。

Also, a ROS 2 workspace that has been built from source may build and install multiple RMW implementations simultaneously. While the core ROS 2 code is being compiled, any RMW implementation that is found will be built if the relevant DDS/RTPS implementation has been installed properly and the relevant environment variables have been configured. For example, if the code for the RMW package for RTI Connext is in the workspace, it will be built if an installation of RTI’s Connext Pro can also be found. For many cases you will find that nodes using different RMW implementations are able to communicate, however this is not true under all circumstances. A list of supported inter-vendor communication configurations is forthcoming.

此外,从源编译的ROS 2工作空间可以同时编译和安装多个RMW实现。在编译核心ROS 2代码时,如果已正确安装相关的DDS / RTPS实现并且已配置相关的环境变量,则将编译找到的任何RMW实现。例如,如果RTI ConnextRMW包的代码在工作区中,那么如果也可以找到RTI的Connext Pro安装,它将被编译。对于许多情况,会发现使用不同RMW实现的节点能够进行通信,但并非所有情况下都是这样。支持的厂商间通信配置列表即将发布。

Default RMW implementation 默认RMW实现

If a ROS 2 workspace has multiple RMW implementations, the default RMW implementation is currently selected as Fast RTPS if it’s available. If the Fast RTPS RMW implementation is not installed, the RMW implementation with the first RMW implementation identifier in alphabetical order will be used. The implementation identifier is the name of the ROS package that provides the RMW implementation, e.g. rmw_fastrtps_cpp. For example, if both rmw_opensplice_cpp and rmw_connext_cpp ROS packages are installed, rmw_connext_cpp would be the default. If rmw_fastrtps_cpp is ever installed, it would be the default. See below for how to specify which RMW implementation is to be used when running the ROS 2 examples.

如果ROS 2工作空间具有多个RMW实现,则默认RMW实现当前被选为快速RTPS(如果可用)。如果未安装快速RTPS RMW实现,将使用具有按字母顺序排列的第一个RMW实现标识符的RMW实现。实现标识符是提供RMW实现的ROS包的名称,例如rmw_fastrtps_cpp。例如,如果同时安装了两个rmw_opensplice_cpp和rmw_connext_cppROS包,则默认为rmw_connext_cpp。如果rmw_fastrtps_cpp曾经安装过,那将是默认设置。请参考下文,了解如何在运行ROS 2示例时指定要使用的RMW实现。

Specifying RMW implementations 指定RMW实现

To have multiple RMW implementations available for use you must have installed our binaries and any additional dependencies for specific RMW implementations, or built ROS 2 from source with multiple RMW implementations in the workspace (they are included by default) and their dependencies are met (for example see the Linux install instructions).

要使多个RMW实现可供使用,必须已安装二进制文件以及特定RMW实现的任何其他依赖项,或者在工作区中使用多个RMW实现从源编译ROS 2(默认包含它们)并且满足它们的依赖性(对于示例请参考Linux安装说明)。

Starting in Beta 2 and above both C++ and Python nodes support an environment variable RMW_IMPLEMENTATION. To choose a different RMW implemenation you can set the environment variable RMW_IMPLEMENTATION to a specific implementation identifier.

从Beta 2及更高版本开始,C ++和Python节点都支持环境变量RMW_IMPLEMENTATION。要选择不同的RMW实现,可以将环境变量RMW_IMPLEMENTATION设置为特定的实现标识符。

To run the talker demo using the C++ and listener using python with the RMW implementation for connext:

使用C ++和接收器使用python和连接器的RMW实现来运行发布器演示:

Bash

RMW_IMPLEMENTATION=rmw_connext_cpp ros2 run demo_nodes_cpp talker

# Run in another terminal

RMW_IMPLEMENTATION=rmw_connext_cpp ros2 run demo_nodes_py listener

Windows cmd.exe

set RMW_IMPLEMENTATION=rmw_connext_cpp

ros2 run demo_nodes_cpp talker

REM run in another terminal

set RMW_IMPLEMENTATION=rmw_connext_cpp

ros2 run demo_nodes_py listener

Adding RMW implementations to your workspace

将RMW实现添加到工作区

Suppose that you have built your ROS 2 workspace with only Fast RTPS installed and therefore only the Fast RTPS RMW implementation built. The last time your workspace was built, any other RMW implementation packages, rmw_connext_cpp for example, were probably unable to find installations of the relevant DDS implementations. If you then install an additional DDS implementation, Connext for example, you will need to re-trigger the check for a Connext installation that occurs when the Connext RMW implementation is being built. You can do this by specifying the --cmake-force-configure flag on your next workspace build, and you should see that the RMW implementation package then gets built for the newly installed DDS implementation.

假设已经编译了仅安装了快速RTPS的ROS 2工作区,因此仅编译了快速RTPS RMW实现。上次编译工作区时,任何其他RMW实现包,如rmw_connext_cpp都可能无法找到相关DDS实现的安装。例如,如果再安装其他DDS实现版本(例如Connext),则需要重新触发对编译Connext RMW实现时发生的Connext安装的检查。可以通过在下一个工作区编译中指定--cmake-force-configure标志来执行此操作,应该看到RMW实现包然后为新安装的DDS实现编译。

It is possible to run into a problem when “rebuilding” the workspace with an additional RMW implementation using the --cmake-force-configure option where the build complains about the default RMW implementation changing. To resolve this, you can either set the default implementation to what is was before with the RMW_IMPLEMENTATION CMake argument or you can delete the build folder for packages that complain and continue the build with --start-with <package name>.

当使用--cmake-force-configure编译提示默认RMW实现更改的选项使用其他RMW实现“重建”工作空间时,可能会遇到问题。要解决此问题,可以将默认实现设置为之前的RMW_IMPLEMENTATION的CMake参数,也可以删除提示并使用--start-with <package name>继续编译。

Troubleshooting 故障排除

Ensuring use of a particular RMW implementation

确保使用特定的RMW实现

ROS 2 Ardent and later ROS 2 Ardent及以后

If the RMW_IMPLEMENTATION environment variable is set to an RMW implementation for which support is not installed, you will see an error message similar to the following if you have only one implementation installed:

如果RMW_IMPLEMENTATION环境变量设置为未安装支持的RMW实现,如果只安装了一个实现,则会看到类似于以下内容的错误消息:

Expected RMW implementation identifier of 'rmw_connext_cpp' but instead found 'rmw_fastrtps_cpp', exiting with 102.

If you have support for multiple RMW implementations installed and you request use of one that is not installed, you will see something similar to:

如果支持安装多个RMW实现,并且请求使用未安装的实现,则将看到类似于以下内容的内容:

Error getting RMW implementation identifier / RMW implementation not installed (expected identifier of 'rmw_connext_cpp'), exiting with 1.

If this occurs, double check that your ROS 2 installation includes support for the RMW implementation that you have specified in the RMW_IMPLEMENTATION environment variable.

如果发生这种情况,请仔细检查ROS 2安装是否包含对在RMW_IMPLEMENTATION环境变量中指定的RMW实现的支持。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年09月12日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Working with multiple ROS 2 middleware implementations
  • 使用多个ROS 2中间件实现
    • Pre-requisites 预备基础
      • Multiple RMW implementations 多个RMW实现
        • Default RMW implementation 默认RMW实现
          • Specifying RMW implementations 指定RMW实现
            • Adding RMW implementations to your workspace
              • 将RMW实现添加到工作区
                • Troubleshooting 故障排除
                  • Ensuring use of a particular RMW implementation
                  • 确保使用特定的RMW实现
              相关产品与服务
              消息队列 TDMQ
              消息队列 TDMQ (Tencent Distributed Message Queue)是腾讯基于 Apache Pulsar 自研的一个云原生消息中间件系列,其中包含兼容Pulsar、RabbitMQ、RocketMQ 等协议的消息队列子产品,得益于其底层计算与存储分离的架构,TDMQ 具备良好的弹性伸缩以及故障恢复能力。
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档