Skip to content

LifecycleNode autostart=True fails when running the same executable twice with different names #445

@tonynajjar

Description

@tonynajjar
# Inspired from launch_ros/examples/lifecycle_autostart_pub_sub_launch.py

import os
import sys


import launch  # noqa: E402
import launch.actions  # noqa: E402
import launch.events  # noqa: E402

import launch_ros.actions  # noqa: E402
import launch_ros.events  # noqa: E402
import launch_ros.events.lifecycle  # noqa: E402


def main(argv=sys.argv[1:]):
    ld = launch.LaunchDescription()
    talker_node = launch_ros.actions.LifecycleNode(
        name='talker',
        namespace='',
        package='lifecycle',
        executable='lifecycle_talker',
        output='screen',
        emulate_tty=True,
        autostart=True)
    talker2_node = launch_ros.actions.LifecycleNode(
        name='talker2',
        namespace='',
        package='lifecycle',
        executable='lifecycle_talker',
        output='screen',
        emulate_tty=True,
        autostart=True)
    ld.add_action(talker_node)
    ld.add_action(talker2_node)
    ls = launch.LaunchService(argv=argv)
    ls.include_launch_description(ld)
    return ls.run()


if __name__ == '__main__':
    main()

run this snippet enough times (10 should be enough) and you'll get the error:

INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [lifecycle_talker-1]: process started with pid [1311355]
[INFO] [lifecycle_talker-2]: process started with pid [1311356]
[ERROR] [launch_ros.utilities.lifecycle_event_manager]: Failed to make transition 'TRANSITION_ACTIVATE' for LifecycleNode '/talker2'
[lifecycle_talker-2] [WARN] [1741364109.137012849] [rcl_lifecycle]: No transition matching 3 found for current state unconfigured
[lifecycle_talker-2] [ERROR] [1741364109.137131130] [talker2]: Unable to start transition 3 from current state unconfigured: Transition is not registered., at ./src/rcl_lifecycle.c:355
[lifecycle_talker-1] [INFO] [1741364109.138277845] [talker]: on_configure() is called.
[lifecycle_talker-1] [INFO] [1741364109.138492406] [talker]: on_activate() is called.
[lifecycle_talker-2] [INFO] [1741364109.138827753] [talker2]: on_configure() is called.

FYI @SteveMacenski as author of the feature (thanks btw)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions