ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

How do I write package.xml?

asked 2015-02-03 05:09:30 -0500

VictorLamoine gravatar image

updated 2015-11-10 06:36:21 -0500

I came across several tutorials about catkin and especially the package.xml tutorial; I wonder how should I write the package.xml. Here is a simple example:

package.xml

<?xml version="1.0"?>
<package>
  <name>ensenso_n10_description</name>
  <version>0.0.0</version>
  <description>Ensenso end effector for Fanuc M10iA</description>
  <maintainer email="my_mail@gmail.com">Name</maintainer>
  <license>All rights reserved</license>

  <buildtool_depend>catkin</buildtool_depend>
<!--
  <run_depend>joint_state_publisher</run_depend>
  <run_depend>robot_state_publisher</run_depend>
  <run_depend>rviz</run_depend>
  <run_depend>xacro</run_depend>
-->
</package>

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(ensenso_n10_description)
find_package(catkin REQUIRED)

catkin_package()

foreach(dir launch meshes urdf)
  install(
    DIRECTORY ${dir}/
    DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/${dir})
endforeach()

I was expecting things not to work with the commented out section, but it turns out it works well without the run_depend tags. I've manually written package.xml but I don't understand how I am supposed to fill the build_depend and run_depend tags.

  1. How do I check that my package.xml is correctly written? (I only know catkin_lint)
  2. In what cases would anything fail if the package.xml is wrong?
  3. Is there a tool that automatically writes the package.xml? (using the CMakeLists.txt for example). If it's not possible, why?
  4. Why is information duplicated between CMakeLists.txt and package.xml?
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2015-02-03 05:49:16 -0500

gvdhoorn gravatar image

updated 2015-02-05 06:46:05 -0500

I was expecting things not to work with the commented out section, but it turns out it works well without the run_depend tags. The full package can be viewed here.

The package manifest is mostly used for resolving dependencies for packages when they are being installed, either from source (using rosdep), or (after processing by Bloom) by the Debian/Fedora/X package manager. The buidfarm also uses this information.

That things still work on your local machine makes perfect sense: you already have all dependencies installed. Removing the run_depends from your manifest does not change that fact.

(note that for Python this is slightly different, as in that case run_depends are also used to setup the Python path in your workspace). (probably not true, see also REP-122/PYTHONPATH, roslib.load_manifest())

I've manually written package.xml but I don't understand how I am supposed to fill the build_depend and run_depend tags.

Most people (at least initially) use the catkin_create_pkg command, with appropriate arguments. If, during development, you find that you need to add more dependencies, simply edit the file by hand, as you have done now.

As to whether things are a run_depend, build_depend or test_depend (and sometimes also why), the How to do common tasks section (from the catkin documentation) is probably very helpful (note: the linked version is for Indigo).

1 . How do I check that my package.xml is correctly written? (I only know catkin_lint)

REP-127 would be the authorative source for information on whether the manifest is 'correctly written'. The catkin/package.xml tutorial you linked would be the more informal version of that.

As to dependencies: catkin_lint actually makes sure that the manifest and CMakeLists.txt are consistent with each other (it also performs syntax and 'best practice' conformance checks). It cannot know whether a dependency you stated in your manifest or CMakeLists.txt is actually needed / correct. It does not parse your C++. You are the only one (at the moment) with that knowledge.

Failing builds would be a sign of missing dependencies in CMakeLists.txt.

2 . In what cases would anything fail if the package.xml is wrong?

See earlier comments.

3 . Is there a tool that automatically writes the package.xml? (using the CMakeLists.txt for example). If it's not possible, why?

I don't know of a tool that can generate package.xml for you, but catkin_lint at least does the consistency checks for you. Whether it would be possible to create such a tool: Python packages would be one example of why that is difficult (with only run_depends, and an almost empty CMakeLists.txt).

4 . Why is information duplicated between CMakeLists.txt and package.xml?

I think others (like @Dirk Thomas, @William) can probably answer this in more detail, but in general I consider CMakeLists.txt to be the build script, while package.xml is where we store mostly other metadata. Some things are duplicated, but (I think) only because it is complicated to deduce generic rules ... (more)

edit flag offensive delete link more

Comments

"(note that for Python this is slightly different, as in that case run_depends are also used to setup the Python path in your workspace)." I do not believe this is correct, the PYTHONPATH should be set independently of the run_depends.

William gravatar image William  ( 2015-02-04 16:59:14 -0500 )edit

I wasn't entirely sure of it myself, but I have had packages where things don't work if I didn't add dependencies to run_depends and rebuilt. Perhaps they were just coincidences.

gvdhoorn gravatar image gvdhoorn  ( 2015-02-05 01:46:50 -0500 )edit

IIUC, you are right @William. I've edited the answer.

gvdhoorn gravatar image gvdhoorn  ( 2015-02-05 06:46:41 -0500 )edit

In response to why stuff is duplicated, I can only answer by saying each place a dependency is used is for a specific reason. And by leaving it out in one place or another you can control how your package uses that dependency. It's hard to guess the intention of the user based on the package.xml.

William gravatar image William  ( 2015-02-09 02:27:11 -0500 )edit

I've explained it a bit before, see: http://answers.ros.org/question/20197...

William gravatar image William  ( 2015-02-09 02:27:17 -0500 )edit

Also, this one sort of explains part of it too: http://answers.ros.org/question/58498...

William gravatar image William  ( 2015-02-09 02:27:51 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-02-03 05:09:30 -0500

Seen: 5,244 times

Last updated: Nov 10 '15