#!/usr/bin/env python3
"""Launch file for patrol mode."""

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


def generate_launch_description():
    params_file_arg = DeclareLaunchArgument(
        'patrol_params_file',
        default_value='patrol_params.yaml',
        description='Patrol parameters file (waypoints, idle behaviors)'
    )

    min_idle_arg = DeclareLaunchArgument(
        'min_idle_time',
        default_value='10',
        description='Minimum idle time at each waypoint'
    )

    max_idle_arg = DeclareLaunchArgument(
        'max_idle_time',
        default_value='30',
        description='Maximum idle time at each waypoint'
    )

    battery_threshold_arg = DeclareLaunchArgument(
        'battery_dock_threshold',
        default_value='25.0',
        description='Battery level to trigger return to dock'
    )

    patrol_node = Node(
        package='saltybot_patrol',
        executable='patrol_node',
        name='patrol_node',
        parameters=[{
            'patrol_params_file': LaunchConfiguration('patrol_params_file'),
            'min_idle_time': LaunchConfiguration('min_idle_time'),
            'max_idle_time': LaunchConfiguration('max_idle_time'),
            'battery_dock_threshold': LaunchConfiguration('battery_dock_threshold'),
        }],
        output='screen',
    )

    return LaunchDescription([
        params_file_arg,
        min_idle_arg,
        max_idle_arg,
        battery_threshold_arg,
        patrol_node,
    ])
