#!/usr/bin/env python3

import os
from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():
    # 创建一个 LaunchDescription 对象来存储所有要启动的节点
    ld = LaunchDescription()

    # 定义一个函数来创建并添加一个 ROS 节点到 LaunchDescription
    def create_node(package, executable, name):
        node = Node(
            package=package,
            executable=executable,
            name=name,
            output="screen",
            # prefix="xterm -geometry 80x40 -fa Monospace -fs 15 -e",  # 在新的 xterm 终端中启动节点
            prefix="gnome-terminal -- bash -c",  # 使用 GNOME 终端启动节点
        )
        return node

    # 添加节点到 LaunchDescription
    # 例子 ：ld.add_action(create_node('package_name', 'executable_name', 'node_name'))
    ld.add_action(create_node("rtk", "rtk_node", "rtk_node"))

    # ld.add_action(create_node("radar", "radar_node", "radar_node"))

    # ld.add_action(create_node("lidar", "lidar_node", "lidar_node"))

    ld.add_action(create_node("pl", "pl_node", "pl_node"))

    ld.add_action(create_node("fu", "fu_node", "fu_node"))

    # ld.add_action(create_node("gather", "gather_node", "gather_node"))

    ld.add_action(create_node("route", "route_node", "route_node"))

    ld.add_action(create_node("sub", "sub_node", "sub_node"))
    # ld.add_action(create_node("sub_jingmen", "sub_jingmen_node", "sub_jingmenb_node"))
    # ld.add_action(create_node("pub_jingmen", "pub_jingmen_node", "pub_jingmen_node"))
    ld.add_action(create_node("pub_gps", "pub_gps_node", "pub_gps_node"))
    ld.add_action(create_node("pub_chassis", "pub_chassis_node", "pub_chassis_node"))

    return ld
