使用变体

元包不直接提供软件,而是依赖于一组其他相关包,为整个包组提供方便的安装机制。[1] [2] 变体是常用 ROS 包组的官方元包列表。

ROS 2 中的不同变体在 REP-2001 中指定。

除了官方变体之外,可能还有针对特定机构或机器人的元包,如 REP-108 中所述。

添加变体

可以通过拉取请求 <https://github.com/ros-infrastructure/rep/blob/master/rep-2001.rst>`_ 向 `REP-2001 贡献更新来提出对 ROS 社区普遍使用的其他变体,该请求描述了新变体中包含的软件包。 机构和机器人特定的变体可以由其各自的维护者直接发布,无需更新 REP-2001。

创建项目特定变体

如果您要创建 ROS 包以在自己的项目中私下使用,则可以使用官方变体作为示例创建特定于您项目的变体。 为此,您只需创建两个文件:

  1. 最小变体包被创建为一个包,其中包含“ament_cmake”构建类型、“ament_cmake”上的“buildtool_depend”和您想要包含在变体中的每个包的“exec_depend”条目。

    <?xml version="1.0"?>
    <?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
    <package format="2">
      <name>my_project_variant</name>
      <version>1.0.0</version>
      <description>A package to aggregate all packages in my_project.</description>
      <maintainer email="maintainer-email">Maintainer Name</maintainer>
      <license>Apache-2.0</license>
      <!-- packages in my_project -->
      <exec_depend>my_project_msgs</exec_depend>
      <exec_depend>my_project_services</exec_depend>
      <exec_depend>my_project_examples</exec_depend>
    
      <export>
        <build_type>ament_cmake</build_type>
      </export>
    </package>
    
  2. A minimal ament_cmake package includes a CMakeLists.txt which registers the package.xml as an ament package for use in ROS 2.

    cmake_minimum_required(VERSION 3.5)
    
    project(my_project_variant NONE)
    find_package(ament_cmake REQUIRED)
    ament_package()
    

You can then build and install your variant package alongside your other private packages.

Creating custom variants with platform-specific tools

Some platforms have tools for creating basic packages that do not require a full ROS build farm environment or equivalent infrastructure. It is possible to use these tools to create platform-dependent variants. This approach does not include support for ROS packaging tools and is platform dependent but requires much less infrastructure to produce if you are creating collections of existing packages rather than a mix of public and private ROS packages. For example, on Debian or Ubuntu systems you can use the equivs utilities. The Debian Administrator’s handbook has a Section on meta-packages.