在Ubuntu 22.04上使用``ros1_bridge``和上游ROS

在Ubuntu 22.04 Jammy Jellyfish上发布的ROS 2 Humble(和Rolling)标志着首个在没有官方ROS 1版本的平台上发布的ROS 2版本。虽然ROS 1 Noetic将在其`长期支持窗口 <https://www.ros.org/reps/rep-0003.html#noetic-ninjemys-may-2020-may-2025>`__ 内继续得到支持,但它只针对Ubuntu 20.04。或者,Debian和Ubuntu中存在一些`ROS 1软件包的上游变体 <https://packages.ubuntu.com/jammy/ros-desktop>`__,它们不作为ROS维护者的官方发行版进行维护。

本指南概述了在Ubuntu 22.04 Jammy Jellyfish上使用这些上游软件包进行ROS 2版本桥接的当前机制。这为仍然依赖ROS 1但希望迁移到更新的ROS 2和Ubuntu版本的用户提供了一条迁移路径。

通过Debian软件包使用ROS 2

目前无法在Ubuntu Jammy上通过Debian软件包安装ROS 2。Ubuntu软件仓库中可用的``catkin-pkg-modules``版本与ROS 2软件包仓库中的版本存在冲突。

如果ROS 2的apt仓库在可用的apt仓库(/etc/apt/sources.list.d)中,将无法安装任何ROS 1软件包。错误信息如下:

$ apt install ros-core-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 ros-core-dev : Depends: catkin but it is not installable
E: Unable to correct problems, you have held broken packages.

要修正此问题,请从您的``sources.list``文件中移除packages.ros.org。如果您遵循了ROS 2安装指南,只需移除``/etc/apt/sources.list.d/ros2.list``文件即可。

目前,为了支持 ros1_bridge,请按照下面的说明从源代码构建ROS 2。

ROS 2 源代码构建

只有通过 ROS 2 源代码构建 的方式才能在 Ubuntu Jammy 上使用 ROS 2。

下面是源代码构建说明中必要的指令摘要。与原指南有较大差异的是,我们跳过使用 ROS 2 的apt存储库,因为存在冲突的软件包。

安装开发工具和ROS工具

由于我们不使用ROS 2的apt存储库,必须通过pip安装``colcon``。

sudo apt update && sudo apt install -y \
  build-essential \
  cmake \
  git \
  python3-flake8 \
  python3-flake8-blind-except \
  python3-flake8-builtins \
  python3-flake8-class-newline \
  python3-flake8-comprehensions \
  python3-flake8-deprecated \
  python3-flake8-docstrings \
  python3-flake8-import-order \
  python3-flake8-quotes \
  python3-pip \
  python3-pytest \
  python3-pytest-cov \
  python3-pytest-repeat \
  python3-pytest-rerunfailures \
  python3-rosdep \
  python3-setuptools \
  wget

# Install colcon from PyPI, rather than apt packages
python3 -m pip install -U colcon-common-extensions vcstool

从这里开始,继续阅读 源码安装指南 来构建ROS 2。

从Ubuntu软件包中安装ROS 1。

sudo apt update && sudo apt install -y ros-core-dev

构建``ros1_bridge``

# Create a workspace for the ros1_bridge
mkdir -p ~/ros1_bridge/src
cd ~/ros1_bridge/src
git clone https://github.com/ros2/ros1_bridge
cd ~/ros1_bridge

# Source the ROS 2 workspace
. ~/ros2_humble/install/local_setup.bash

# Build
colcon build

在构建完所有``ros1_bridge``之后,ros1_bridge示例 的其余部分应该可以在新安装的环境下正常工作