Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make OnStateTransition work with the new ComposableNode descriptions #41

Open
ralph-lange opened this issue Jul 18, 2019 · 7 comments
Open
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ralph-lange
Copy link

Feature request

Feature description

In Dashing, the ComposableNodeContainer action and the corresponding ComposableNode description were introduced. A ComposableNode description also takes a managed node (aka lifecycle node). However, configuring and activating a lifecycle node by a ComposableNode description (instead of a LifecycleNode action) fails:

on_inactive_node_B_handler = launch.actions.RegisterEventHandler(
        launch_ros.event_handlers.OnStateTransition(
            target_lifecycle_node=node_B,
            goal_state='inactive',
            entities=[configure_node_A]))

> Caught exception in launch (see debug for traceback): OnStateTransition 
  requires a 'LifecycleNode' action as the target

Using a matcher is also not possible but gives an exception.

on_inactive_node_B_handler = launch.actions.RegisterEventHandler(
        launch_ros.event_handlers.OnStateTransition(
            matcher=launch_ros.events.lifecycle.matches_node_name("/example/node_B"),
            goal_state='inactive',
            entities=[configure_node_A]))

> ... return lambda action: action.node_name == node_name
  AttributeError: 'Shutdown' object has no attribute 'node_name'

When calling matches_action with a ComposableNode description is simply does nothing:

    configure_node_B = launch.actions.EmitEvent(
        event=launch_ros.events.lifecycle.ChangeState(
            lifecycle_node_matcher=launch.events.matchers.matches_action(node_B),
            transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE,
        )
    )

Probably, the whole matching and event system for lifecycle action and events has to be extended for ComposbleNode descriptions.

As a starting for experiments, you may use the damped_pendulum_with_transport_delay_as_composed_node.launch.py of the fmi_adapter_examples package, cf. https://github.com/boschresearch/fmi_adapter_ros2/blob/0.1.5/fmi_adapter_examples/launch/damped_pendulum_with_transport_delay_as_composed_node.launch.py and remove comments in lines 90 to 103 and 106 to 108.

@JWhitleyWork
Copy link

Has there been any movement on this?

@hidmic hidmic added the help wanted Extra attention is needed label Apr 16, 2020
knatsuki added a commit to knatsuki/joystick_drivers that referenced this issue Jun 1, 2020
@vincentrou
Copy link

This issue seems to be linked to this ongoing refactoring : ros2/design#272 (comment)

@hellantos
Copy link
Contributor

I have an experimental, heavily refactored prototype for the launch_ros composition part in https://github.com/ipa-cmh/launch_ros_experimental that does enable this.
It changes quite a lot of things from an architectural standpoint:

  • ComposableNodeContainer:
    Listens to LoadNodeEvent, then loads the node via request specified in event.
  • ComposableNode now an Action:
    It waits for the specified container to become available.
    Then it triggers loading its component by emitting an event to the ComposableNodeContainer that will then load the Node.
  • ComposableLifecyleNode inherits from ComposableNode:
    It waits for the specified container to become available.
    Then it triggers loading its component by emitting an event to the ComposableNodeContainer that will then load the Node.
    It has the same Event interface as LifecycleNode.

It breaks the existing API, so this probably not mergeable, just wanted to point out it exists.

You can use it like this:

import launch
from launch_ros_experimental.actions import ComposableNode, ComposableNodeContainer, ComposableLifecycleNode
from launch_ros.actions import LifecycleTransition
from lifecycle_msgs.msg import Transition

def generate_launch_description():
    """Generate launch description with multiple components."""
    container = ComposableNodeContainer(
            name='my_container',
            namespace='',
            package='rclcpp_components',
            executable='component_container',
            output='screen',
    )

    node = ComposableNode(
        package='composition',
        component='composition::Talker',
        name='talker',
        target_container='my_container'
    )
    lifecycle_node = ComposableLifecycleNode(
        package='composition',
        component='composition::LifecycleTalker',
        name='lctalker',
        namespace='',
        target_container='my_container'  
    )

    lifecycle_node_1 = ComposableLifecycleNode(
        package='composition',
        component='composition::LifecycleTalker',
        name='lctalker_1',
        namespace='',
        target_container='my_container'  
    )

    lifecycle_transition = LifecycleTransition(
        lifecycle_node_names=['lctalker', 'lctalker_1'],
        transitions_ids=[
            Transition.TRANSITION_CONFIGURE,
            Transition.TRANSITION_ACTIVATE]
    )


    return launch.LaunchDescription([container, node, lifecycle_node, lifecycle_node_1, lifecycle_transition])

For testing you can use https://github.com/ipa-cmh/demos/tree/lifecycle_components which has the composition LifecycleTalker component.

@ZhenshengLee
Copy link

ros2/launch#672 is related.

I wonder if I should create all issues in this repo, rather than https://github.com/ros2/launch repo?

@ZhenshengLee
Copy link

I have an experimental, heavily refactored prototype for the launch_ros composition part in https://github.com/ipa-cmh/launch_ros_experimental that does enable this.

@ipa-cmh thanks for your repo!

I've tryied your repo in my project.

It seems that your repo doesnot support Foxy version am I right?

Which versions do you plan to support?

Thanks.

@ZhenshengLee
Copy link

Also, launch_ros.events.lifecycle.matches_node_name($LifecycleNodeComponent$) doesnot work.

@leonce-m
Copy link

Any news on this development? It's been 5 years already and we still can't properly use the launch Event system to manage the lifecycle of composable nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants