Ask Your Question
1

launch component into existing container

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

highmax1234 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 https://github.com/ros-perception/ima... 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 -0500

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 433 times

Last updated: May 11 '21