Inferensys

Glossary

ROS Package

A ROS Package is the fundamental organizational and distribution unit for software in the Robot Operating System (ROS), containing executables, libraries, configuration files, and a manifest.
Overhead shot of a beautifully lit strategy meeting in a modern WeWork hot desk area, designers and executives gathered around a live AI system diagram projected on smart table surface.
GLOSSARY

What is a ROS Package?

The fundamental unit of organization and software distribution in the Robot Operating System (ROS).

A ROS Package is the atomic unit of software organization in ROS, containing all the files—executables, libraries, configuration files, and datasets—necessary to provide a specific piece of functionality, such as a driver, algorithm, or utility. Every package is defined by a mandatory package.xml manifest file that declares its metadata, dependencies, and exported resources. This modular structure enables developers to share, reuse, and build upon discrete components within the larger ROS ecosystem.

Packages are built and managed using ROS-specific tools like catkin (ROS 1) or colcon (ROS 2), which handle dependency resolution and compilation. They are typically organized within a workspace, where the build system creates an isolated development and installation environment. This encapsulation allows complex robotic systems to be decomposed into manageable, interoperable units, facilitating collaborative development, version control, and system integration.

DEFINITIVE STRUCTURE

Core Components of a ROS Package

A ROS Package is the fundamental unit of software organization in the Robot Operating System. It is a directory with a prescribed structure and a manifest file that enables the ROS build and runtime tools to identify, build, and manage dependencies.

01

The Package Manifest (package.xml)

The package.xml file is the mandatory metadata file that defines the package's identity and dependencies. It is an XML file that must be present in the root of every package.

  • Declares package properties: Name, version, description, maintainer, and license.
  • Specifies dependencies: Categorizes required packages as build dependencies (needed at compile time), execution dependencies (needed at runtime), test dependencies, and build tool dependencies.
  • Enables tooling: The ROS build system (catkin, colcon) and package managers (rosdep) read this file to resolve and install dependencies automatically.

Example essential tags:

xml
<package format="3">
  <name>my_robot_driver</name>
  <version>1.0.0</version>
  <description>A driver for my custom robot.</description>
  <maintainer email="[email protected]">Jane Developer</maintainer>
  <license>Apache 2.0</license>
  <depend>roscpp</depend>
  <depend>sensor_msgs</depend>
</package>
02

The CMakeLists.txt File

The CMakeLists.txt file is the build instruction manual for C++ (or mixed-language) packages. It uses the CMake build system, extended with ROS-specific macros, to define how the package's executables and libraries are compiled and linked.

  • Finds dependencies: Uses find_package() to locate other ROS packages and system libraries.
  • Declares build targets: Defines executables (nodes) and libraries with add_executable() and add_library().
  • Links dependencies: Specifies link libraries and include directories with target_link_libraries() and include_directories().
  • Installs artifacts: Uses install() commands to specify where built binaries, libraries, and launch files should be placed for system-wide use.
  • ROS Macros: Utilizes convenience macros like ament_package() (ROS 2) or catkin_package() (ROS 1) to finalize package configuration.

A pure Python package may omit this file, relying solely on package.xml and a setup.py or setup.cfg.

03

Source Code Directories (src/, include/)

These directories contain the package's core logic. Their structure follows standard software conventions.

  • src/ (source): Contains the .cpp source files for C++ nodes and libraries. For Python packages, this often contains a Python module directory (e.g., src/my_package/).
  • include/<package_name>/ (headers): Contains the .h or .hpp header files for C++ libraries. The subdirectory named after the package prevents header filename collisions across the system.

Example Node: A simple publisher node might be located at src/talker.cpp. Its corresponding header, if part of a library, would be in include/my_package/talker.hpp.

This separation enforces clean interfaces and allows other packages to include this package's headers correctly using the #include <my_package/talker.hpp> syntax.

04

Launch and Configuration Directories (launch/, config/)

These directories hold files that configure and orchestrate the system at runtime, separating configuration from core logic.

  • launch/: Contains launch files (.launch.py in ROS 2, .launch or .launch.py in ROS 1). These files are scripts that:
    • Start multiple nodes simultaneously.
    • Set ROS parameters.
    • Remap topic names.
    • Define node namespaces.
    • Group nodes into composable containers (ROS 2).
  • config/ (or params/): Contains YAML configuration files used to set node parameters. This allows parameters (e.g., controller gains, sensor settings) to be easily modified without recompiling code.

Key Benefit: This structure enables reproducible system bring-up. A complex robot can be started with a single command like ros2 launch my_robot_bringup robot.launch.py, which references launch and config files from multiple packages.

05

Message, Service, and Action Definitions (msg/, srv/, action/)

These optional directories define custom communication interfaces, making the package's APIs explicit and reusable.

  • msg/: Contains .msg files that define the structure of custom messages published on topics.
    • Example Pose2D.msg: float64 x\nfloat64 y\nfloat64 theta
  • srv/: Contains .srv files that define the request and response structures for custom services.
    • Example AddTwoInts.srv: int64 a\nint64 b\n---\nint64 sum
  • action/: Contains .action files that define the goal, feedback, and result structures for custom long-running actions (ROS 1 & 2).
    • Example NavigateToPose.action: geometry_msgs/PoseStamped goal_pose\n---\ngeometry_msgs/PoseStamped result\n---\ngeometry_msgs/PoseStamped feedback

Build Process: During compilation, the ROS build system automatically generates language-specific code (C++, Python, etc.) from these definition files, creating the classes and functions used to send and receive this data.

06

Test and Documentation Directories (test/, doc/)

These directories support package quality, verification, and usability.

  • test/: Contains unit, integration, and system tests.
    • C++ Tests: Use the Google Test (gtest) framework, integrated via CMake's catkin_add_gtest() or ament_add_gtest().
    • Python Tests: Use the pytest framework.
    • Launch Tests: Test the correct startup and interaction of nodes using ROS launch testing frameworks.
    • Running colcon test from the workspace root executes all package tests.
  • doc/ or package.xml tags: While a doc/ folder can hold manual documentation, the primary documentation mechanism is the <export> tag in package.xml, which can point to a URI for online API documentation (e.g., hosted by Doxygen or Sphinx).

Importance: A well-tested package with clear documentation is essential for integration into larger, reliable robotic systems and for use by other developers in the community.

FUNDAMENTAL UNIT

How ROS Packages Work: Build, Dependency, and Discovery

A ROS Package is the atomic unit of software organization and distribution in the Robot Operating System (ROS). It encapsulates a specific piece of functionality, such as a driver, algorithm, or dataset, and is defined by its manifest file and directory structure.

A ROS Package is the fundamental unit for organizing, building, and distributing software in ROS, defined by a directory containing a mandatory package.xml manifest file and, typically, a CMakeLists.txt build file. The package.xml file declares metadata, dependencies (build, run, test), and export information, enabling the ROS build system (colcon) and runtime tools to discover, compile, and resolve inter-package relationships. This modular structure allows developers to share, version, and reuse discrete robotic capabilities—from sensor drivers to perception algorithms—within a larger system.

During the build process, tools like colcon parse the package.xml to create a dependency graph, ensuring packages are compiled in the correct order. At runtime, ROS tools like ros2 pkg use this manifest to locate package resources via the ROS_PACKAGE_PATH. This strict packaging convention enforces modularity and explicit dependency management, which are critical for managing the complexity of large-scale robotic software stacks composed of hundreds of interoperating components.

ROS PACKAGE

Frequently Asked Questions

A ROS Package is the fundamental unit of organization and distribution in the Robot Operating System (ROS). This FAQ addresses common developer questions about its structure, purpose, and lifecycle.

A ROS Package is the primary unit for organizing and distributing software in the Robot Operating System (ROS). It is a directory containing a specific collection of files—including source code, libraries, datasets, configuration files, and a mandatory manifest file (package.xml)—that together provide a discrete piece of functionality for a robotic system.

Every package must contain a package.xml file, which is the package manifest. This XML file defines metadata about the package, such as its name, version, description, author, license, and, most critically, its dependencies on other ROS packages and external libraries. This structure enables the ROS build system (catkin for ROS 1, colcon for ROS 2) to discover, compile, and manage dependencies across the entire workspace. A typical package might contain nodes for perception, a library for custom message types, launch files for starting the system, and configuration parameters.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.