"""Launch diagnostic self-test node."""
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

def generate_launch_description():
    package_dir = get_package_share_directory("saltybot_diagnostics")
    config_dir = os.path.join(package_dir, "config")

    return LaunchDescription([
        DeclareLaunchArgument(
            "config_file",
            default_value=os.path.join(config_dir, "diagnostic_checks.yaml"),
            description="Diagnostic checks configuration",
        ),
        DeclareLaunchArgument(
            "enable_startup_check", default_value="true",
            description="Enable startup checks",
        ),
        DeclareLaunchArgument(
            "enable_runtime_monitoring", default_value="true",
            description="Enable runtime monitoring",
        ),
        DeclareLaunchArgument(
            "log_directory", default_value="/home/seb/saltybot-data/diagnostics",
            description="Log directory",
        ),
        Node(
            package="saltybot_diagnostics",
            executable="diagnostics_node",
            name="diagnostics",
            output="screen",
            parameters=[{
                "config_file": LaunchConfiguration("config_file"),
                "enable_startup_check": LaunchConfiguration("enable_startup_check"),
                "enable_runtime_monitoring": LaunchConfiguration("enable_runtime_monitoring"),
                "log_directory": LaunchConfiguration("log_directory"),
                "monitoring_frequency": 1.0,
            }],
        ),
    ])
