#!/usr/bin/env python3
from launch import LaunchDescription
from launch_ros.actions import Node, SetParameter
from ament_index_python.packages import get_package_share_directory
import os

def generate_launch_description():
    # 获取参数文件路径
    pkg_share = get_package_share_directory('zbw_slamtoolbox')
    params_file = os.path.join(pkg_share, 'config', 'mapper_params_online_async.yaml')

    set_use_sim_time = SetParameter(name='use_sim_time', value=False)
    
    # 创建SLAM Toolbox节点
    slam_toolbox_node = Node(
        package='slam_toolbox',
        executable='async_slam_toolbox_node',  # 或 sync_slam_toolbox_node
        name='slam_toolbox',
        output='screen',
        parameters=[params_file]
    )
    
    
    return LaunchDescription([
        set_use_sim_time,
        slam_toolbox_node
    ])