Exemplo n.º 1
0
def test_launch_composable_node_without_component_name():
    node = ComposableNodeContainer(package='rclcpp_components',
                                   executable='component_container',
                                   node_name=TEST_NODE_NAME,
                                   node_namespace=TEST_NODE_NAMESPACE,
                                   composable_node_descriptions=[
                                       ComposableNode(
                                           package='composition',
                                           node_plugin='composition::Listener',
                                           node_namespace=TEST_NODE_NAMESPACE)
                                   ],
                                   output='screen')
    ld = LaunchDescription([node])
    context = _launch(ld)
    assert get_node_name_count(context,
                               f'{TEST_NODE_NAMESPACE}/{TEST_NODE_NAME}') == 1
    # Unlike for Nodes, launch_ros is able to track component node names even when
    # node_name is not provided for the component
    assert get_node_name_count(context, f'{TEST_NODE_NAMESPACE}/listener') == 1
Exemplo n.º 2
0
def test_launch_nodes_with_same_names(pytestconfig):
    node1 = Node(
        package='demo_nodes_py',
        node_executable='listener_qos',
        node_name=TEST_NODE_NAME,
        node_namespace=TEST_NODE_NAMESPACE,
        output='screen',
    )

    node2 = LifecycleNode(
        package='lifecycle',
        node_executable='lifecycle_listener',
        node_name=TEST_NODE_NAME,
        node_namespace=TEST_NODE_NAMESPACE,
        output='screen',
    )

    node3 = ComposableNodeContainer(
        package='rclcpp_components',
        node_executable='component_container',
        node_name=TEST_NODE_NAME,
        node_namespace=TEST_NODE_NAMESPACE,
        composable_node_descriptions=[
            ComposableNode(
                package='composition',
                node_plugin='composition::Listener',
                node_name=TEST_NODE_NAME
            )
        ],
        output='screen'
    )

    ld = LaunchDescription([node1, node2, node3])
    context = _launch(ld)
    captured = pytestconfig.pluginmanager.getplugin('capturemanager').read_global_capture()
    assert get_node_name_count(context, f'{TEST_NODE_NAMESPACE}/{TEST_NODE_NAME}') == 3
    expected_line = f'there are now at least 3 nodes with the name {TEST_NODE_NAMESPACE}' \
        f'/{TEST_NODE_NAME} created within this launch context'
    assert expected_line in captured.out
    assert get_node_name_count(context, f'/{TEST_NODE_NAME}') == 1
Exemplo n.º 3
0
def test_launch_nodes_with_different_names():
    node1 = Node(
        package='demo_nodes_py',
        executable='listener_qos',
        node_name=f'{TEST_NODE_NAME}_1',
        node_namespace=TEST_NODE_NAMESPACE,
        output='screen',
    )

    node2 = LifecycleNode(
        package='lifecycle',
        executable='lifecycle_listener',
        node_name=f'{TEST_NODE_NAME}_2',
        node_namespace=TEST_NODE_NAMESPACE,
        output='screen',
    )

    node3 = ComposableNodeContainer(
        package='rclcpp_components',
        executable='component_container',
        node_name=f'{TEST_NODE_NAME}_3',
        node_namespace=TEST_NODE_NAMESPACE,
        composable_node_descriptions=[
            ComposableNode(
                package='composition',
                node_plugin='composition::Listener',
                node_name=f'{TEST_NODE_NAME}_4',
            )
        ],
        output='screen')

    ld = LaunchDescription([node1, node2, node3])
    context = _launch(ld)
    assert get_node_name_count(
        context, f'{TEST_NODE_NAMESPACE}/{TEST_NODE_NAME}_1') == 1
    assert get_node_name_count(
        context, f'{TEST_NODE_NAMESPACE}/{TEST_NODE_NAME}_2') == 1
    assert get_node_name_count(
        context, f'{TEST_NODE_NAMESPACE}/{TEST_NODE_NAME}_3') == 1
    assert get_node_name_count(context, f'/{TEST_NODE_NAME}_4') == 1