ROS 2 文档中文翻译:RMW 实现与 DDS 实现 5 篇(Jazzy Jalisco)
原文来源:ROS 2 Documentation(Jazzy)—— Installation 章节下的 RMW implementations 部分。承接前三份译文,本文件按文档侧边栏顺序翻译接下来的 5 个页面:
- RMW 实现(总览)
- Eclipse Cyclone DDS
- GurumNetworks GurumDDS
- RTI Connext DDS
- eProsima Fast DDS
命令中的版本占位符已按 Jazzy 版本代入(
jazzy)。
1. RMW 实现(总览)
默认情况下,ROS 2 使用 DDS 作为其中间件。它兼容多家 DDS 或 RTPS(DDS 的线上传输协议)厂商的实现,目前支持 eProsima 的 Fast DDS、RTI 的 Connext DDS、Eclipse Cyclone DDS 以及 GurumNetworks GurumDDS。
它也支持 Zenoh 等非 DDS 的 RMW 实现。
各发行版支持的 RMW 厂商请参阅 REP-2000。
默认的 RMW 厂商是 eProsima 的 Fast DDS。
查看所有可选项:
- DDS 实现:介绍如何使用 DDS(即本文第 2–5 篇)。
- 非 DDS 实现:介绍如何使用非 DDS 实现(如 Zenoh,尚未翻译,如需可继续)。
2. Eclipse Cyclone DDS
Eclipse Cyclone DDS 是一个性能出色且稳健的开源 DDS 实现。Cyclone DDS 作为一个 Eclipse IoT 项目完全公开开发。另请参阅:https://projects.eclipse.org/projects/iot.cyclonedds
前置条件
已安装 rosdep(参见 rosdep 使用教程)。
安装软件包
最简单的方式是从 ROS 2 apt 仓库安装:
$ sudo apt install ros-jazzy-rmw-cyclonedds-cpp从源码构建
从源码构建是另一种安装方式。
首先,在 ROS 2 工作区的源码目录中克隆 Cyclone DDS 和 rmw_cyclonedds。要确定应检出的正确分支,你需要查看你的 ROS 发行版的 ros2.repos 文件中指定的版本。
或者,你也可以运行以下命令来获取 Cyclone DDS 所需的正确分支/标签:
$ CYCLONEDDS_BRANCH=$(curl -s https://raw.githubusercontent.com/ros2/ros2/refs/heads/jazzy/ros2.repos | grep -A 3 "eclipse-cyclonedds/cyclonedds:" | grep "version:" | awk '{print $2}')然后克隆并检出代码:
$ cd ros2_ws/src $ git clone https://github.com/ros2/rmw_cyclonedds ros2/rmw_cyclonedds -b jazzy $ git clone https://github.com/eclipse-cyclonedds/cyclonedds eclipse-cyclonedds/cyclonedds -b ${CYCLONEDDS_BRANCH}接着,安装 Cyclone DDS 所需的软件包:
$ cd .. $ rosdep install --from src -i最后,运行 colcon 构建:
$ colcon build --symlink-install切换到 rmw_cyclonedds
通过指定环境变量,从其他 RMW 切换到 rmw_cyclonedds:
$ export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp另请参阅:使用多个 RMW 实现。
运行 talker 和 listener
现在运行talker和listener来测试 Cyclone DDS:
$ source /opt/ros/jazzy/setup.bash $ ros2 run demo_nodes_cpp talker$ source /opt/ros/jazzy/setup.bash $ ros2 run demo_nodes_cpp listener3. GurumNetworks GurumDDS
rmw_gurumdds是使用 GurumNetworks GurumDDS 实现的 ROS 中间件接口。关于 GurumDDS 的更多信息,请访问 GurumNetworks 官网。
前置条件
本指南假设你已经完成了 ROS 2 环境配置,无论是通过 deb 软件包安装 ROS 2,还是在 Ubuntu 上从源码构建 ROS 2(均见本系列译文第一份文件)。
版本要求(详见 README):
| ROS 2 发行版 | GurumDDS 版本 |
|---|---|
| rolling | >= 3.2.0 |
| lyrical | >= 3.2.0 |
| kilted | >= 3.2.0 |
| jazzy | >= 3.2.0 |
| humble | 3.1.x |
GurumDDS 的 deb 软件包已在 Ubuntu 的 ROS 2 apt 仓库中提供。GurumDDS 的 Windows 二进制安装程序即将推出。
你可以从 GurumDDS 免费试用页面获取免费试用许可证。
获取许可证后,请将其放置在以下位置:/etc/gurumnet
安装
方式一:从 ROS 2 apt 仓库安装(推荐)
$ sudo apt install ros-jazzy-rmw-gurumdds-cpp这会同时安装rmw_gurumdds_cpp和gurumdds。
方式二:从源码构建
- 克隆仓库:
$ cd ros2_ws/src $ git clone https://github.com/ros2/rmw_gurumdds -b jazzy ros2/rmw_gurumdds- 安装依赖:
$ cd .. $ rosdep install --from src -i --rosdistro jazzy- 使用 colcon 构建工作区:
$ colcon build --symlink-install切换到 rmw_gurumdds
通过设置环境变量,从其他 RMW 实现切换到 rmw_gurumdds:
$ export RMW_IMPLEMENTATION=rmw_gurumdds_cpp关于使用多个 RMW 实现的更多信息,请参阅使用多个 RMW 实现。
测试安装
运行talker和listener节点来验证安装:
$ source /opt/ros/jazzy/setup.bash $ ros2 run demo_nodes_cpp talker$ source /opt/ros/jazzy/setup.bash $ ros2 run demo_nodes_cpp listener如果两个节点通信成功,说明你的安装工作正常。
注意:在运行这些命令之前,记得先 source 你的 ROS 2 配置脚本。
4. RTI Connext DDS
RTI Connext DDS 在全球 2000 多个要求最苛刻的系统设计中备受信赖,以最高水平的性能、可靠性和安全性分发关键的实时数据。它可免费用于原型开发、研究、非商业和学术用途。更多信息以及支持和商业许可的选项,请访问 RTI 官网。
前置条件
安装 RTI Connext DDS
要构建和使用rmw_connextdds,需要一个与所使用的 ROS 2 发行版兼容的 Connext DDS 版本。使用 apt 安装rmw_connextdds时会包含 Connext DDS;如果从源码构建,则需要手动安装。下表列出了使用apt安装的 Connext DDS 版本,以及从源码构建所需的版本:
| ROS 2 发行版 | 使用 apt 安装的版本 | 从源码构建所需版本 |
|---|---|---|
| rolling | 不适用 | 7.7.0 |
| lyrical | 7.7.0 | 7.7.0 |
| kilted | 7.3.0 | 7.3.0 |
| jazzy | 6.0.1 | 6.0.1 |
| humble | 6.0.1 | 6.0.1 |
RTI Connext Pro 可通过多种渠道获取:
ROS 2 apt 仓库
ROS 2 用户可以使用以下命令,从 ROS apt 仓库安装适用于 x86_64 Linux 的 RTI Connext DDS 库(非商业用途版本):
v7.3.0:
$ sudo apt update && sudo apt install -q -y rti-connext-dds-7.3.0-rosv6.0.1(Jazzy 对应版本):
$ sudo apt update && sudo apt install -q -y rti-connext-dds-6.0.1
该软件包仅包含 RTI Connext 核心 DDS 库,不包含完整的 Connext Professional 工具套件和运行时服务。请注意,使用 apt 安装rmw_connextdds时会自动安装这些 Connext 库。
其他安装选项
Connext Robotics Toolkit 包含完整的 Connext 工具套件和基础设施服务。它可以通过 apt 一步完成 ROS 和 Connext 的安装,并可免费用于原型开发、研究、非商业和学术用途。
关于在各种平台上构建和调优 RMW 与 ROS 2 应用、以及启用 DDS Security 的详细说明,可在 RTI ROS 社区页面找到。
安装 rmw_connextdds 二进制包
要从 ROS 2 apt 仓库安装rmw_connextdds和 Connext 库的二进制包,使用以下命令:
$ sudo apt update && sudo apt install -q -y ros-jazzy-rmw-connextdds从源码构建 rmw_connextdds
从源码构建可以确保 RMW 与你的系统匹配并正确安装。以下说明假设构建主机和目标平台均为 Linux x86_64;面向其他平台和目标(包括 Arm、Windows 和 macOS)的构建说明,请见 RTI ROS 社区页面。
将rmw_connextdds仓库克隆到你的 ROS 2 工作区,并选择与所使用的 ROS 2 发行版匹配的分支:
$ mkdir -p ros2_ws/src $ cd ros2_ws $ git clone -b jazzy https://github.com/ros2/rmw_connextdds src/rmw_connextdds配置环境,帮助 colcon 找到 RTI Connext 的安装位置。可以手动把环境变量NDDSHOME设置为 RTI Connext 的安装位置,也可以使用 RTI Connext 安装中自带的脚本:
$ source ${RTI_CONNEXT_INSTALL_LOCATION}/resource/scripts/rtisetenv_x64Linux4gcc7.3.0.bash确保你已经配置好 ROS 2 环境:
$ source /opt/ros/jazzy/setup.bash使用 colcon 构建该 RMW:
$ colcon build --symlink-install构建成功完成后,记得 source 工作区的配置文件:
$ source install/setup.bash使用构建好的 rmw_connextdds
设置环境变量RMW_IMPLEMENTATION,告诉 ROS 2 使用哪个 RMW:
$ export RMW_IMPLEMENTATION=rmw_connextdds另请参阅:使用多个 RMW 实现。
运行 talker 和 listener
现在运行talker和listener来测试 RTI Connext DDS:
$ source /opt/ros/jazzy/setup.bash $ ros2 run demo_nodes_cpp talker$ source /opt/ros/jazzy/setup.bash $ ros2 run demo_nodes_cpp listener5. eProsima Fast DDS
eProsima Fast DDS 是一个面向实时嵌入式架构和操作系统的完整开源 DDS 实现。另请参阅:https://www.eprosima.com/index.php/products-all/eprosima-fast-dds
前置条件
已安装 rosdep(参见 rosdep 使用教程)。
安装软件包
最简单的方式是从 ROS 2 apt 仓库安装:
$ sudo apt install ros-jazzy-rmw-fastrtps-cpp从源码构建
从源码构建是另一种安装方式。
首先,在 ROS 2 工作区的源码目录中克隆 Fast DDS 和 rmw_fastrtps:
$ cd ros2_ws/src $ git clone https://github.com/ros2/rmw_fastrtps ros2/rmw_fastrtps -b jazzy $ git clone https://github.com/eProsima/Fast-DDS eProsima/fastrtps接着,安装 Fast DDS 所需的软件包:
$ cd .. $ rosdep install --from src -i最后,运行 colcon 构建:
$ colcon build --symlink-install切换到 rmw_fastrtps
可以通过指定环境变量来选择 eProsima Fast DDS RMW:
$ export RMW_IMPLEMENTATION=rmw_fastrtps_cpp另请参阅:使用多个 RMW 实现。
运行 talker 和 listener
现在运行talker和listener来测试 Fast DDS:
$ source /opt/ros/jazzy/setup.bash $ ros2 run demo_nodes_cpp talker$ source /opt/ros/jazzy/setup.bash $ ros2 run demo_nodes_cpp listener附注
- 本译文基于 ROS 2 官方文档Jazzy分支,命令中的版本占位符已替换为
jazzy。 - Installation 章节剩余未译页面:DDS 实现总览(DDS-Implementations,目录页)、非 DDS 实现(Non-DDS implementations,含 Zenoh)、ROS 2 镜像站(Mirrors)。如需继续,可随时提出。