专栏首页机器人课程与技术ROS2编程基础课程--中间件

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

版权声明:本文为博主原创文章,遵循 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实现的支持。

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • ROS2机器人笔记20-08-18

    如何用图形化界面而非代码在仿真环境中配置机器人模型?模型通常为刚体,弹性物体或者柔性物体仿真十分消耗资源!

    zhangrelay
  • 最火爆的ROS教程-机器人操作系统入门-Melodic-

    原文链接:https://github.com/anchuanxu/ROS-Academy-for-Beginners...

    zhangrelay
  • 在Ubuntu 18.04 LTS安装ROS Melodic版机器人操作系统

    ROS Melodic版本在5月23日推出正式版,这是ROS第三款长期支持版本,前2版LTS分别为:indigo;kinetic。

    zhangrelay
  • 三星Bixby中文(普通话)版发布,这是一款“真正能说人话”的语音助手

    镁客网
  • SSM框架原理,作用及使用方法

    SSM框架是spring MVC ,spring和mybatis框架的整合,是标准的MVC模式,将整个系统划分为表现层,controller层,service层...

    Java团长
  • SSM框架原理,作用及使用方法

    注:本公众号纯属个人公益公众号!不存在任何收费项目!免费分享所有学习资料!只求大家多多支持!多多关注!!

    Java学习
  • SSM框架原理,作用及使用方法

    SSM框架是spring MVC ,spring和mybatis框架的整合,是标准的MVC模式,将整个系统划分为表现层,controller层,service层...

    程序工场
  • SSM框架原理,作用及使用方法

    SSM框架是spring MVC ,spring和mybatis框架的整合,是标准的MVC模式,将整个系统划分为表现层,controller层,service层...

    程序员宝库
  • 浅谈:强大的Hexo

    Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown(或其他渲染引擎)解析文章,在几秒内,即可利用靓丽的主题生成静态网页。

    BessCroft
  • 人工智能推动人机交互创新,三星Bixby带来了哪些不一样的体验?| 测评

    镁客网

扫码关注云+社区

领取腾讯云代金券