ROS Package

How to package.

package.xml

Use package format 2.0, which removes the distinction between <run_depend> and <build_depend> and makes this more compact.

Use spaces, 2-wide as indentation.

Example:

<?xml version="1.0"?>
<package format="2">
  <name>mav_local_planner</name>
  <version>0.0.0</version>
  <description>
    Local planner with multiple configurable components for planning
    straight-line paths to waypoints, checking global plans for collisions,
    and doing local obstacle avoidance.
  </description>

  <maintainer email="[email protected]">Helen Oleynikova</maintainer>

  <license>BSD</license>

  <buildtool_depend>catkin</buildtool_depend>
  <buildtool_depend>catkin_simple</buildtool_depend>

  <depend>mav_msgs</depend>
  <depend>mav_planning_utils</depend>
  <depend>planner_ompl</depend>
  <depend>planner_base</depend>
  <depend>planning_msgs</depend>
  <depend>roscpp</depend>
  <depend>tf</depend>
</package>

CMakeLists.txt

You should use catkin_simple rather than the old-style catkin lists, since they make everything easier. Use spaces, 2-wide as indentation.

A few tips:

  • catkin_simple(ALL_DEPS_REQUIRED) will make sure that all dependencies in the package.xml above are found on the system and loaded.

  • Make a library called ${PROJECT_NAME} and link any executables against it.

  • If you're outputting messages, this is done automatically by catkin simple. However, if you have executables and messages in the same package (prefer not to do this, just have a whatever_msgs package instead), you need to add this to after your executable/library so that things are built in the right order: add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS})

See the documentation at the link above, and this example:

Folder/file structure

Your package should look something like the example below. See the ROS Package Documentation for more details.

Keep in mind:

  • Your headers should be in include/PACKAGE_NAME/header.h

  • Your source files should be in the src/ folder.

  • Ideally, if you have ROS parameters in your node, you should have the default values and descriptions in a .yaml file in the cfg folder.

Example default_local_planner_params.yaml. Always have units when available!

Last updated

Was this helpful?