Launch Files and Parameter Management
Learning Objectives
- Understand the role of launch files in ROS 2.
- Learn basics of parameter management.
- Examine example launch file code.
What are Launch Files?
Launch files allow you to start multiple nodes, configure their parameters, and manage the robot's lifecycle from a single file (usually written in Python).
Parameter Management
Parameters are configuration values for nodes, enabling easy tuning without recompiling code.
Launch File Example
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='my_package',
executable='my_node',
name='my_node',
parameters=[{'param1': 'value1'}]
)
])
Takeaways
- Launch files are crucial for multi-node systems.
- Parameters allow for runtime configuration.
Review Questions
- Why are launch files preferred over starting nodes individually?