1

我正在尝试在 Ubuntu 16.04 上使用 ROS 动力学构建 catkin 工作空间,但这是发生的错误,并且 package.XML 为空。所以我该怎么做?有什么建议么?我也在使用凉亭,只想构建 CMake,但我做不到。我是 CMake 和 Ubuntu 的新手。

evadro@evadro-PowerEdge-T620:~/catkin_ws$ catkin build
-----------------------------------------------------------
Profile:                     default
Extending:             [env] /opt/ros/kinetic
Workspace:                   /home/evadro/catkin_ws
-----------------------------------------------------------
Build Space:        [exists] /home/evadro/catkin_ws/build
Devel Space:        [exists] /home/evadro/catkin_ws/devel
Install Space:      [unused] /home/evadro/catkin_ws/install
Log Space:          [exists] /home/evadro/catkin_ws/logs
Source Space:       [exists] /home/evadro/catkin_ws/src
DESTDIR:            [unused] None
-----------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
-----------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
-----------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
-----------------------------------------------------------
Workspace configuration appears valid.
-----------------------------------------------------------
Traceback (most recent call last):
  File "/usr/bin/catkin", line 11, in <module>
    load_entry_point('catkin-tools==0.4.5', 'console_scripts', 'catkin')()
  File "/usr/lib/python2.7/dist-packages/catkin_tools/commands/catkin.py", line 272, in main
    catkin_main(sysargs)
  File "/usr/lib/python2.7/dist-packages/catkin_tools/commands/catkin.py", line 267, in catkin_main
    sys.exit(args.main(args) or 0)
  File "/usr/lib/python2.7/dist-packages/catkin_tools/verbs/catkin_build/cli.py", line 422, in main
    summarize_build=opts.summarize  # Can be True, False, or None
  File "/usr/lib/python2.7/dist-packages/catkin_tools/verbs/catkin_build/build.py", line 283, in build_isolated_workspace
    workspace_packages = find_packages(context.source_space_abs, exclude_subspaces=True, warnings=[])
  File "/usr/lib/python2.7/dist-packages/catkin_pkg/packages.py", line 89, in find_packages
    packages = find_packages_allowing_duplicates(basepath, exclude_paths=exclude_paths, exclude_subspaces=exclude_subspaces, warnings=warnings)
  File "/usr/lib/python2.7/dist-packages/catkin_pkg/packages.py", line 150, in find_packages_allowing_duplicates
    xml, filename=filename, warnings=warnings)
  File "/usr/lib/python2.7/dist-packages/catkin_pkg/package.py", line 598, in parse_package_string
    raise InvalidPackage('The manifest contains invalid XML:\n%s' % ex, filename)
catkin_pkg.package.InvalidPackage: Error(s) in package '/home/evadro/catkin_ws/src/./package.xml':
The manifest contains invalid XML:
no element found: line 1, column 0
4

1 回答 1

0

你的问题

你不能有一个空的package.xml. package.xml 包含有关您的包的所有信息,其中一些是必需的(例如包的名称)。这就是为什么您的错误代码在最后告诉您的原因:

清单包含无效的 XML:未找到元素:第 1 行,第 0 列

另外:你会把你的package.xml? 您不是package.xml为工作空间创建一个,而是为一个包创建一个,它可以位于工作空间

如何修复你的 package.xml

ros.org 上有一个非常好的教程,介绍如何在这里创建一个简单的包。如果你真的想创建一个包含空包的工作区,你可以转到src/你的工作区(除了这个 src 文件夹之外不需要包含任何东西)并运行以下命令:

catkin_create_pkg theNameOfMyNewPackage

编辑:如果您想知道如何构建您的 package.xml 以及如何组织您的依赖项,这里还有一个 Ros 提供的非常有用的页面

...但你真的想要一个吗?

但是对我来说,您的问题听起来很像您实际上并不想拥有一个空包(因此根本没有 package.xml),而只是一个空的工作区。您可以通过在工作空间内的任何位置导航来实现这一点(同样,除了这个 src 文件夹之外不需要包含任何东西)并运行以下命令:

cakin init

之后,您仍然可以添加一些包 - 就像使用脚本一样catkin_create_pkg

于 2020-02-12T00:58:00.240 回答