For rosbuild, see: rosbuild/Packages
Software in ROS is organized in packages. A package might contain ROS nodes, a ROS-independent library, a dataset, configuration files, a third-party piece of software, or anything else that logically constitutes a useful module. The goal of these packages it to provide this useful functionality in an easy-to-consume manner so that software can be easily reused. In general, ROS packages follow a "Goldilocks" principle: enough functionality to be useful, but not too much that the package is heavyweight and difficult to use from other software.
Packages are easy to create by hand or with tools like catkin_create_pkg. A ROS package is simply a directory descended from ROS_PACKAGE_PATH (see ROS Environment Variables) that has a package.xml file in it. Packages are the most atomic unit of build and the unit of release. This means that a package is the smallest individual thing you can build in ROS and it is the way software is bundled for release (meaning, for example, there is one debian package for each ROS package), respectively.
Please see the catkin/package.xml section for documentation on how to read and write package.xml files.
Common Files and Directories
ROS packages tend to follow a common structure. Here are some of the directories and files you may notice.
include/package_name: C++ include headers (make sure to export in the CMakeLists.txt)
src/package_name/: Source files, especially Python source that are exported to other packages.
scripts/: executable scripts
CMakeLists.txt: CMake build file (see catkin/CMakeLists.txt)
package.xml: Package catkin/package.xml
CHANGELOG.rst: Many packages will define a changelog which can be automatically injected into binary packaging and into the wiki page for the package
Packages are a very central concept to how files in ROS are organized, so there are quite a few tools in ROS that help you manage them. This includes:
rospack: find and retrieve information about packages
catkin_create_pkg: create a new package
catkin_make: build a workspace of packages
rosdep: install system dependencies of a package
rqt: In rqt there is a plugin called "Introspection/Package Graph", which visualizes package dependencies as a graph
There are also extensions to common Unix shells that provide additional functionality to help you navigate and use packages. The most commonly used of these is rosbash, which provides ROS-variants of common Unix shell commands. The most commonly used of these is roscd, which performs a cd to the directory of a package, e.g.
Client Library Support
In Python, you can use the RosPack class in the rospkg library to get information about ROS packages. For example:
See more at rospkg API index.
In C++, you can use ros::package in the roslib package to get information about ROS packages. For example:
#include <ros/package.h> ... std::string path = ros::package::getPath("roslib"); using package::V_string; V_string packages; ros::package::getAll(packages);