Unit 07 · lesson

Create an `ament_python` Package

Create an ament_python Package

Work inside the workspace source directory:

source /opt/ros/jazzy/setup.bash
cd ~/ros2_ws/src

Create the package:

ros2 pkg create \
  --build-type ament_python \
  --license Apache-2.0 \
  robotnix_pubsub

The official Jazzy package tutorial uses the same ros2 pkg create --build-type ament_python pattern.

Inspect what ROS generated

find robotnix_pubsub -maxdepth 3 -type f | sort

You should find files such as:

robotnix_pubsub/package.xml
robotnix_pubsub/setup.py
robotnix_pubsub/setup.cfg
robotnix_pubsub/resource/robotnix_pubsub
robotnix_pubsub/robotnix_pubsub/__init__.py

Why the package name repeats

The outer robotnix_pubsub/ is the ROS package directory.

The inner robotnix_pubsub/ is the Python module/package where your Python node files live.

They share a name intentionally, but they have different roles.

Checkpoint

Label the generated tree with:

  • ROS package metadata;
  • Python module;
  • resource marker;
  • installation configuration.