$\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.
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 ROS 2 Python package will contain, at least, the following contents.
package.xml
file containing meta-information about the packagesetup.py
containing instructions for how to install the packagesetup.cfg
is required when a package has executable, so ros2 run can find them/<package_name>
- a directory with the same name as your package, used by ROS 2 tools to find your package, contains __init__.py
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
A ROS 2 CMake package will contain, at least, the following contents.
package.xml
file containing meta-information about the package