Unit 08 · lesson
Read a Python Launch Description
A basic ROS 2 Python launch file usually returns a LaunchDescription containing actions.
Create a scratch example and read it before running it:
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='robotnix_pubsub',
executable='talker',
name='course_talker',
output='screen',
),
Node(
package='robotnix_pubsub',
executable='listener',
name='course_listener',
output='screen',
),
])
Read one Node action
package='robotnix_pubsub'
selects the package.
executable='talker'
selects the installed executable entry point.
name='course_talker'
sets the runtime node name.
output='screen'
makes process output visible in the launch terminal.
Prediction
Before launching, predict:
nodes visible:
topic visible:
which process prints publisher logs:
which process prints subscriber logs:
Checkpoint
Explain why the launch file does not replace talker.py or listener.py.