$\color{white}\colorbox{FE9227}{Building momentum and expanding understanding!}$

▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░ 40%


A ROS 2 package is a container for code that can be installed and shared with others. Python and CMake are the two client libraries used to create packages, each with their own minimum required contents. A single workspace can contain multiple packages, but not nested packages. To create a package, navigate to the src folder and use the command ros2 pkg create --build-type ament_python package_name. Packages can be built together using colcon build in the workspace root.

packages1.mp4

1. Background

A package can be considered a container 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.

ROS 2 packages can be created using two different client libraries, Python and C++. ROS 2 Python and CMake packages each have their own minimum required contents.

a. Python

A ROS 2 Python package will contain, at least, the following contents.

The simplest possible package may have a file structure that looks like this:

my_package/
		my_package
			__init__.py
		setup.py
		package.xml
		resource
			my_package

b. CMake

A ROS 2 CMake package will contain, at least, the following contents.