ROS学习笔记6(package.xml)

概述

软件包清单是一个XML文件名为package.xml中必须包括与任何兼容包的根文件夹。此文件定义有关包的属性,例如包名称,版本号,作者,维护者以及其他catkin包的依赖关系。请注意,这个概念类似于传统rosbuild构建系统中使用的manifest.xml文件。

您的系统包依赖关系在package.xml中声明。如果缺少或不正确,您可能可以从源代码构建,并在自己的机器上运行测试,但是当发布到ROS社区时,您的软件包将无法正常工作。其他依赖于这些信息来安装他们使用您的软件包所需的软件。

格式2 (推荐)

这是新软件包的推荐格式。还建议将较旧的格式1包迁移为格式2.有关从格式1迁移到格式2的说明,请参阅catkin API文档中的从格式1迁移到格式2 。格式2的完整文档可以在catkin API文档中找到。更多信息可以在REP 140 - Package Manifest Format Two Specification中找到

基本结构

每个package.xml文件都有<package>标签作为根标记文件。

<package format="2">

</package>

所需标签

有一小部分标签需要嵌套在<package>标签中,以使包清单完整。

  • <name> - 包的名称

  • <version> - 包的版本号(需要3个点分隔的整数)

  • <description> - 包装内容的描述

  • <maintainer> - 维护包的人员的名称

  • <license> - 发布代码的软件许可证(例如GPL,BSD,ASL)。

例如,这里是一个名为foo_core的虚构包的包清单。 

<package format="2">
  <name>foo_core</name>
  <version>1.2.4</version>
  <description>
  This package provides foo capability.
  </description>
  <maintainer email="[email protected]">Ivana Bildbotz</maintainer>
  <license>BSD</license>
</package>

依赖关系

具有最小标签的包清单不指定对其他包的任何依赖关系。软件包可以有六种依赖关系:

  • 构建依赖关系:指定构建此包所需的包。在构建时需要这些软件包中的任何文件时才是这种情况。这可以包括在编译时的头文件,链接到这些包的库文件或在构建时需要任何其他资源(特别是当这些包在CMake 中是find_package()时)。在交叉编译场景中,构建依赖关系针对目标体系结构。

  • 构建导出依赖关系:指定根据此包构建库的时候所需的包。当您将此头文件包含在此包中的公用头文件中时(特别是当CMake中的catkin_package()中声明为(CATKIN_DEPENDS 时),就是这种情况。

  • 执行依赖关系:指定在此程序包中运行代码所需的软件包。当您依赖此程序包中的共享库(尤其是当CMake 中的catkin_package()中声明为(CATKIN_DEPENDS 时),就是这种情况。

  • 测试依赖关系:仅指定单元测试的附加依赖项。他们不应该将已经提到的任何依赖关系重复为构建或运行依赖关系。

  • 构建工具依赖关系:指定此软件包需要构建自身的构建系统工具。通常唯一的构建工具是catkin。在交叉编译场景中,构建工具依赖关系用于执行编译的架构。

  • 文档工具依赖关系:指定此软件包需要生成文档的文档工具。

  • Build Dependencies specify which packages are needed to build this package. This is the case when any file from these packages is required at build time. This can be including headers from these packages at compilation time, linking against libraries from these packages or requiring any other resource at build time (especially when these packages are find_package()-ed in CMake). In a cross-compilation scenario build dependencies are for the targeted architecture.

  • Build Export Dependencies specify which packages are needed to build libraries against this package. This is the case when you transitively include their headers in public headers in this package (especially when these packages are declared as (CATKIN_)DEPENDS in catkin_package() in CMake).

  • Execution Dependencies specify which packages are needed to run code in this package. This is the case when you depend on shared libraries in this package (especially when these packages are declared as (CATKIN_)DEPENDS in catkin_package() in CMake).

  • Test Dependencies specify only additional dependencies for unit tests. They should never duplicate any dependencies already mentioned as build or run dependencies.

  • Build Tool Dependencies specify build system tools which this package needs to build itself. Typically the only build tool needed is catkin. In a cross-compilation scenario build tool dependencies are for the architecture on which the compilation is performed.

  • Documentation Tool Dependencies specify documentation tools which this package needs to generate documentation.

These six types of dependencies are specified using the following respective tags:

  • <depend> specifies that a dependency is a build, export, and execution dependency. This is the most commonly used dependency tag.指定依赖关系是构建、导出和执行这些依赖关系。是最常用的依赖关系。
  • <buildtool_depend>

  • <build_depend>

  • <build_export_depend>

  • <exec_depend>

  • <test_depend>

  • <doc_depend>

所有包至少有一个依赖关系,构建工具依赖于catkin,如下例所示。

<package format="2">
  <name>foo_core</name>
  <version>1.2.4</version>
  <description>
    This package provides foo capability.
  </description>
  <maintainer email="[email protected]">Ivana Bildbotz</maintainer>
  <license>BSD</license>

  <buildtool_depend>catkin</buildtool_depend>
</package>
指定构建,执行,测试和文档依赖关系的更现实的示例可能如下所示。
<package format="2">
  <name>foo_core</name>
  <version>1.2.4</version>
  <description>
    This package provides foo capability.
  </description>
  <maintainer email="[email protected]">Ivana Bildbotz</maintainer>
  <license>BSD</license>

  <url>http://ros.org/wiki/foo_core</url>
  <author>Ivana Bildbotz</author>

  <buildtool_depend>catkin</buildtool_depend>

  <depend>roscpp</depend>
  <depend>std_msgs</depend>

  <build_depend>message_generation</build_depend>

  <exec_depend>message_runtime</exec_depend>
  <exec_depend>rospy</exec_depend>

  <test_depend>python-mock</test_depend>

  <doc_depend>doxygen</doc_depend>
</package>

关于依赖关系的更多细节可以在这里的 catkin API文档中找到

Metapackages

将多个软件包分组为单个逻辑软件包通常很方便。这可以通过metapackages来实现。元包是在package.xml中具有以下导出标记的普通包:

 <export>
   <metapackage />
 </export>

Other than a required <buildtool_depends> dependency on catkin, metapackages can only have execution dependencies on packages of which they group.

Additionally a metapackage has a required, boilerplate CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8.3)
project(<PACKAGE_NAME>)
find_package(catkin REQUIRED)
catkin_metapackage()

注意:将<PACKAGE_NAME>替换为metapackage的名称。

Additional Tags

  • <url> - A URL for information on the package, typically a wiki page on ros.org.

  • <author> - The author(s) of the package

猜你喜欢

转载自blog.csdn.net/qq_27806947/article/details/82084707