Unit 08 · lesson

Install Launch Files With the Python Package

Running a launch file from its directory proves the file works.

A stronger package should install the launch file so ROS can find it by package name.

This integration step builds on the ament_python packaging model from Unit 7.

Update setup.py

At the top add:

import os
from glob import glob

Inside data_files, keep the generated package/resource entries and add:

(os.path.join('share', package_name, 'launch'), glob('launch/*.launch.py')),

The relevant shape becomes:

data_files=[
    ('share/ament_index/resource_index/packages',
        ['resource/' + package_name]),
    ('share/' + package_name, ['package.xml']),
    (os.path.join('share', package_name, 'launch'),
        glob('launch/*.launch.py')),
],

Declare launch runtime support

The pinned launch tutorial recommends adding an execution dependency on ros2launch for packages that provide launch files:

<exec_depend>ros2launch</exec_depend>

Rebuild

cd ~/ros2_ws
source /opt/ros/jazzy/setup.bash
colcon build --packages-select robotnix_pubsub --symlink-install

Open a clean terminal and source the overlay.

Now try:

ros2 launch robotnix_pubsub student_system.launch.py

Checkpoint

Explain why the launch file could work from its source directory yet still be missing from ros2 launch <package> ... before installation metadata was updated.