#!/usr/bin/env python3
# ============================================================================
# real_bringup.launch.py
# 功能：实车基础 bringup — 底盘驱动 + 激光雷达 + TF 树
#
# 适用场景：
#   - 单独调试底盘通信和传感器数据
#   - 遥控测试（无导航）
#   - 作为其他 launch 文件的基础模块
#
# 启动内容：
#   origincar_base bringup   — 串口驱动 + EKF + IMU 滤波 + TF + robot_state_publisher
#   lslidar_driver          — 镭神激光雷达 → /scan
#
# 使用方式：
#   ros2 launch gc_navigation2_real real_bringup.launch.py
# ============================================================================

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument
from launch.launch_description_sources import PythonLaunchDescriptionSource


def generate_launch_description():
    """生成 LaunchDescription，启动实车底盘 + 雷达 + TF（无导航）"""

    # ============================ 1. 包路径 =========================================
    origincar_base_dir = get_package_share_directory('origincar_base')

    # ============================ 2. 实车底盘 bringup ===============================
    # 注：origincar_bringup 已包含 robot_state_publisher + joint_state_publisher + 静态 TF
    origincar_bringup = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            [origincar_base_dir, '/launch', '/origincar_bringup.launch.py']),
    )

    # ============================ 3. 镭神激光雷达驱动 ===============================
    lslidar_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            [get_package_share_directory('lslidar_driver'),
             '/launch', '/lsn10_launch.py']),
    )

    # ============================ 4. 组装 LaunchDescription =========================
    return LaunchDescription([
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            description='使用仿真时间（实车必须为 false）'),

        origincar_bringup,
        lslidar_launch,
    ])
