ROS学习笔记6(package.xml)

原文链接: http://wiki.ros.org/catkin/package.xml

1 概述

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

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

2 格式2 (推荐)

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

2.1 基本结构

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



2.2 所需标签

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

  •  - 包的名称

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

  •  - 包装内容的描述

  •  - 维护包的人员的名称

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

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


  foo_core
  1.2.4
  
  This package provides foo capability.
  
  Ivana Bildbotz
  BSD

2.3 依赖关系

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

  • 构建依赖关系:指定构建此包所需的包。在构建时需要这些软件包中的任何文件时才是这种情况。这可以包括在编译时的头文件,链接到这些包的库文件或在构建时需要任何其他资源(特别是当这些包在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:

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

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


  foo_core
  1.2.4
  
    This package provides foo capability.
  
  Ivana Bildbotz
  BSD

  catkin
指定构建,执行,测试和文档依赖关系的更现实的示例可能如下所示。

  foo_core
  1.2.4
  
    This package provides foo capability.
  
  Ivana Bildbotz
  BSD

  http://ros.org/wiki/foo_core
  Ivana Bildbotz

  catkin

  roscpp
  std_msgs

  message_generation

  message_runtime
  rospy

  python-mock

  doxygen

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

3 Metapackages

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

 
   
 

Other than a required 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()
find_package(catkin REQUIRED)
catkin_metapackage()

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

4 Additional Tags

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

  • - The author(s) of the package

补充

下面是对每个语句的说明。
■ 这是一个定义文档语法的语句,随后的内容表明在遵循xml版本1.0。
从这个语句到最后的部分是ROS功能包的配置部分。
功能包的名称。使用创建功能包时输入的功能包名称。正如其他选项,用户可以随时更改。
功能包的版本。可以自由指定。
功能包的简要说明。通常用两到三句话描述。
提供功能包管理者的姓名和电子邮件地址。
记录版权许可证。写BSD、MIT、Apache、GPLv3或LGPLv3即可。
记录描述功能包的说明,如网页、错误管理、存储库的地址等。根据功能包的类型,用户可以填写网站、错误跟踪(bugtracker)或存储库的地址。
记录参与功能包开发的开发人员的姓名和电子邮件地址。如果涉及多位开发人员,只需在下一行添加标签。
描述构建系统的依赖关系。我们正在使用catkin 构建系统,因此输入catkin。
在编写功能包时写下您所依赖的功能包的名称。
填写运行功能包时依赖的功能包的名称。
填写测试功能包时依赖的功能包名称。

在使用ROS中未指定的标签名称时会用到。最广泛使用的情况是元功能包的情况,这时用   格式表明是元功能包。
  在export标签中使用的官方标签声明,当前功能包为一个元功能包时声明它。

你可能感兴趣的:(ROS学习笔记)