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

举报
zhangrelay 发表于 2021/07/15 02:30:40 2021/07/15
【摘要】 Working with multiple ROS 2 middleware implementations  使用多个ROS 2中间件实现 This page explains the default RMW implementation and how to specify an alternative.  此网页解释了默认的RMW实现以及如何指...

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实现版本支持开箱即用(在撰写本文时,如,快速RTPSRTI 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_cpprmw_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_IMPLEMENTATIONCMake参数,也可以删除提示使用--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实现的支持。

文章来源: zhangrelay.blog.csdn.net,作者:zhangrelay,版权归原作者所有,如需转载,请联系作者。

原文链接:zhangrelay.blog.csdn.net/article/details/100773655

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。