~ 9/18/24

Intro

description

A package is an organizational unit for your ROS 2 code. If you want to be able to install your code or share it with others, then you’ll need it organized in a package. With packages, you can release your ROS 2 work and allow others to build and use it easily.

Package creation in ROS 2 uses ament as its build system and colcon as its build tool. You can create a package using either CMake or Python, which are officially supported, though other build types do exist.

ROS2 Python packages

my_package/
β”œβ”€β”€ package.xml    # File containing meta-information about the package
β”œβ”€β”€ resource/
β”‚   └── my_package # Marker file for the package.
β”œβ”€β”€ setup.cfg      # Required when a package has executables, so `ros2 run` can locate them.
β”œβ”€β”€ setup.py       # Contains instructions for how to install the package.
└── my_package/    # A directory with the same name as your package, used by ROS 2 tools to locate your package; it 
                   # contains `__init__.py`.

ROS2 CMake Packages

my_package/  
β”œβ”€β”€ CMakeLists.txt      # Describes how to build the code within the package  
β”œβ”€β”€ include/  
β”‚   └── my_package/     # Directory containing the public headers for the package  
β”œβ”€β”€ package.xml         # File containing meta-information about the package  
└── src/                # Directory containing the source code for the package  

Related

Packages