"""tracking.launch.py — launch the TrackingFusionNode with default params."""

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():
    pkg_share = get_package_share_directory("saltybot_social_tracking")
    default_params = os.path.join(pkg_share, "config", "tracking_params.yaml")

    return LaunchDescription([
        DeclareLaunchArgument(
            "params_file",
            default_value=default_params,
            description="Path to tracking fusion parameter YAML file",
        ),
        DeclareLaunchArgument(
            "control_rate",
            default_value="20.0",
            description="KF predict + publish rate (Hz)",
        ),
        DeclareLaunchArgument(
            "predict_timeout",
            default_value="3.0",
            description="Max KF coast time before stopping publish (s)",
        ),
        Node(
            package="saltybot_social_tracking",
            executable="tracking_fusion_node",
            name="tracking_fusion",
            output="screen",
            parameters=[
                LaunchConfiguration("params_file"),
                {
                    "control_rate":    LaunchConfiguration("control_rate"),
                    "predict_timeout": LaunchConfiguration("predict_timeout"),
                },
            ],
        ),
    ])
