ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

launch component into existing container

asked 2021-05-11 14:35:32 -0600

highmax1234 gravatar image

updated 2023-05-02 09:07:54 -0600

130s gravatar image

I want to launch a component into an existing container. Can anybody help me with this error?

As far as I can see, my code is identical with image_pipeline/stereo_image_proc/launch/stereo_image_proc.launch.py , which uses LoadComposableNodes too. However, the foxy branch does not contain this action anymore. Is it maybe deprecated in foxy? Is there an alternative?

When I run a container in bash#0 with

ros2 run rclcpp_components component_container

and then execute the following launch file in bash#1:

#!/usr/bin/python3
import launch
import launch.actions
import launch.substitutions
from launch_ros.descriptions import ComposableNode
from launch_ros.actions import LoadComposableNodes

def generate_launch_description():
    ld = launch.LaunchDescription()
    comp_node = ComposableNode(
                package="composition",
                plugin="composition::Talker",
                name='compose_name',
                namespace='compose_namespace',
                parameters=[],
                remappings=[],
            )

    load_component = LoadComposableNodes(
        composable_node_descriptions=[comp_node],
        target_container='/ComponentManager'),

    ld.add_action(load_component)
    return ld

I get the following error:

ros2 launch src/my_package/launch/test.launch.py 
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2021-05-11-21-28-08-187318-ROS_WS-2144061
[INFO] [launch]: Default logging verbosity is set to INFO
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:274> exception=AttributeError("'tuple' object has no attribute 'describe_sub_entities'")>
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 276, in _process_one_event
    await self.__process_event(next_event)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 296, in __process_event
    visit_all_entities_and_collect_futures(entity, self.__context))
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
    sub_entities = entity.visit(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
    return self.execute(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/include_launch_description.py", line 140, in execute
    declared_launch_arguments = launch_description.get_launch_arguments()
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description.py", line 126, in get_launch_arguments
    process_entities(self.entities, _conditional_inclusion=conditional_inclusion)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description.py", line 120, in process_entities
    entity.describe_sub_entities(), _conditional_inclusion=False)
AttributeError: 'tuple' object has no attribute 'describe_sub_entities'
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-11 15:09:27 -0600

highmax1234 gravatar image

Turns out it works when I use Launch Configuration:

#!/usr/bin/python3
import launch
import launch.actions
import launch.substitutions
from launch.substitutions import  LaunchConfiguration
from launch.conditions import LaunchConfigurationEquals, LaunchConfigurationNotEquals
from launch_ros.actions.lifecycle_node import LifecycleNode 
from launch_ros.descriptions import ComposableNode
from launch_ros.actions import ComposableNodeContainer, LoadComposableNodes
from launch.actions import DeclareLaunchArgument

def generate_launch_description():
    ld = launch.LaunchDescription()
    DeclareLaunchArgument(
        name='container', default_value='',
        description=(
            'Name of an existing node container to load launched nodes into. '
            'If unset, a new container will be created.'
        )
    ),
    receiver_node = ComposableNode(
                package="receiver_simulation",
                plugin="receiver_simulation::ReceiverNode",
                name='smart7',
                namespace='receiver_simulation',
                parameters=[],
                remappings=[],
            )

    container = ComposableNodeContainer(
        condition=LaunchConfigurationNotEquals('container', ''),
        name='receiver_simulation',
        namespace='/receiver_simulation',
        package='rclcpp_components',
        executable='component_container',
        composable_node_descriptions=[
            receiver_node
        ]
    )
    lcn = LoadComposableNodes(
        condition=LaunchConfigurationEquals('container', ''),
        composable_node_descriptions=[receiver_node],
        target_container=LaunchConfiguration('container'),
    )

    ld.add_action(container)
    ld.add_action(lcn)
    return ld
edit flag offensive delete link more

Comments

In fact, you made a mistake in your code.

load_component = LoadComposableNodes(
    composable_node_descriptions=[comp_node],
    target_container='/ComponentManager'),

The code block makes your interpreter assume that load_component is a tuple type variable

IgararA gravatar image IgararA  ( 2022-11-12 01:57:40 -0600 )edit

I keep hitting similar error message (in a lot of my cases it's list instead tuple as in OP though) so leaving a comment; Something is complaining the format is not right, but the err msg unfortunately doesn't make it clear. At minimum better to improve the err msg (will file a ticket once I have time but if anyone else can do that that's awesome).

130s gravatar image 130s  ( 2023-05-02 13:09:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2021-05-11 14:35:32 -0600

Seen: 3,514 times

Last updated: May 02 '23