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


def generate_launch_description():
    scan_topic = LaunchConfiguration('scan_topic')
    combined_odom_topic = LaunchConfiguration('combined_odom_topic')
    wall_config = LaunchConfiguration('wall_config')
    port = LaunchConfiguration('port')

    return LaunchDescription([
        DeclareLaunchArgument('scan_topic', default_value='/scan'),
        DeclareLaunchArgument('combined_odom_topic', default_value='/odom_combined'),
        DeclareLaunchArgument(
            'wall_config',
            default_value='/home/sunrise/yiliao_ws/src/origincar_base/config/wall_map_calibration (2).json'),
        DeclareLaunchArgument('port', default_value='8772'),

        Node(
            package='origincar_base',
            executable='wall_preview_server',
            name='wall_preview_server',
            output='screen',
            parameters=[{
                'scan_topic': scan_topic,
                'combined_odom_topic': combined_odom_topic,
                'config_path': wall_config,
                'port': port,
            }],
        ),
    ])
