from launch import LaunchDescription
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode

def generate_launch_description():
    container = ComposableNodeContainer(
        name='motor_container',
        namespace='',
        package='rclcpp_components',
        executable='component_container',
        composable_node_descriptions=[
            ComposableNode(
                package='unitree_motor_serial_driver',
                plugin='unitree_motor_serial_driver::MotorControlNode',
                name='unitree_motor_serial_driver',
                parameters=[
                    {'serial_port': '/dev/ttyACM0'},  # 修改默认串口路径
                    {'serial_retry_count': 5},
                    {'serial_retry_delay_ms': 1000}
                ],
                remappings=[
                    ('motor_cmds', 'motor_cmds'),
                    ('data_motors', 'data_motors')
                ]
            )
        ],
        output='screen',
    )

    return LaunchDescription([container])