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


def generate_launch_description():
    return LaunchDescription([
        DeclareLaunchArgument("chassis_host", default_value="192.168.1.100"),
        DeclareLaunchArgument("chassis_port", default_value="9000"),
        DeclareLaunchArgument("chassis_timeout_ms", default_value="5000"),
        DeclareLaunchArgument("control_host", default_value="192.168.1.100"),
        DeclareLaunchArgument("control_port", default_value="9000"),
        DeclareLaunchArgument("control_timeout_ms", default_value="5000"),
        Node(
            package="vehicle_agent_gateway",
            executable="vehicle_agent_gateway_node",
            output="screen",
            parameters=[{
                "chassis_host": LaunchConfiguration("chassis_host"),
                "chassis_port": ParameterValue(LaunchConfiguration("chassis_port"), value_type=int),
                "chassis_timeout_ms": ParameterValue(LaunchConfiguration("chassis_timeout_ms"), value_type=int),
                "control_host": LaunchConfiguration("control_host"),
                "control_port": ParameterValue(LaunchConfiguration("control_port"), value_type=int),
                "control_timeout_ms": ParameterValue(LaunchConfiguration("control_timeout_ms"), value_type=int),
            }],
        ),
    ])
