"""system_monitor.launch.py — Launch the Jetson system monitor node (Issue #631)."""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description() -> LaunchDescription:
    pkg_share = FindPackageShare("saltybot_system_monitor")

    config_arg = DeclareLaunchArgument(
        "config_file",
        default_value=PathJoinSubstitution([pkg_share, "config", "system_monitor.yaml"]),
        description="Path to the system monitor YAML config file",
    )

    node = Node(
        package="saltybot_system_monitor",
        executable="system_monitor_node",
        name="system_monitor_node",
        output="screen",
        parameters=[LaunchConfiguration("config_file")],
    )

    return LaunchDescription([config_arg, node])
