"""Launch file for saltybot_uwb_geofence node."""

from pathlib import Path

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description() -> LaunchDescription:
    pkg_share = str(
        Path(__file__).parent.parent / "config" / "uwb_geofence_zones.yaml"
    )

    return LaunchDescription(
        [
            DeclareLaunchArgument(
                "zones_file",
                default_value=pkg_share,
                description="Path to YAML zones config file",
            ),
            DeclareLaunchArgument(
                "transition_time",
                default_value="0.5",
                description="Speed ramp time in seconds",
            ),
            DeclareLaunchArgument(
                "frequency",
                default_value="20.0",
                description="Node update frequency in Hz",
            ),
            Node(
                package="saltybot_uwb_geofence",
                executable="uwb_geofence_node",
                name="uwb_geofence",
                output="screen",
                parameters=[
                    {
                        "zones_file": LaunchConfiguration("zones_file"),
                        "transition_time": LaunchConfiguration("transition_time"),
                        "frequency": LaunchConfiguration("frequency"),
                    }
                ],
            ),
        ]
    )
