Skip to content

Conversation

@mergify
Copy link

@mergify mergify bot commented Jul 25, 2025

This resolves #418 which implements autostarting lifecycle nodes. This is complete and ready for a review

You'll notice a couple of key changes worth explaining:

  1. There is a new is_lifecycle_node attribute of the node and lifecycle nodes which is needed to remove a circular dependency on the LifecycleNode within the LifecycleTransition class which only is type checking. I replace this type check with checking if a non-None object (1) has the attribute at all and (2) has a lifecycle attribute with appropriate logging between the difference of a non-lifecycle node being attempted vs a non-node. This has been tested as well to function using the demos.

  2. You will also notice that I refactored lifecycle node to have a separate util LifecycleEventManager, who handles the event emitting, handling, and topic listening for lifecycle nodes. This way, this can be used in lifecycle-components as well! No changes were made here except removing the self.__current_state variable which was completely unused. The LifecycleEventManager is only created if the node requests autostart at Launch time and otherwise has no overhead nor exposes the interfaces/event handler/emitter if its a non-lifecycle node.

  3. The component nodes don't add a / before the node names with the namespaces. This messes with the node event matcher. I add in a leading / so that the action.node_name == node_name which has the / forcably applied in the node event matcher

  4. I tested LifecycleNode, ComposableNodeContainer, LoadCompoableNodes for all cases: autostart=True autostart=False, and autostart field not supplied. You can also run any experiments you like using the 2 extra launch files I provide in the examples directory which shows all the features at work/


    This is an automatic backport of pull request Autostarting lifecycle nodes and example launch file demo #430 done by Mergify.

@mergify mergify bot added the conflicts label Jul 25, 2025
@mergify
Copy link
Author

mergify bot commented Jul 25, 2025

Cherry-pick of 3569f0d has failed:

On branch mergify/bp/humble/pr-430
Your branch is up to date with 'origin/humble'.

You are currently cherry-picking commit 3569f0d.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   launch_ros/examples/lifecycle_autostart_pub_sub_launch.py
	new file:   launch_ros/examples/lifecycle_component_autostart_pub_sub_launch.py
	modified:   launch_ros/launch_ros/actions/lifecycle_node.py
	modified:   launch_ros/launch_ros/descriptions/__init__.py
	new file:   launch_ros/launch_ros/descriptions/composable_lifecycle_node.py
	modified:   launch_ros/launch_ros/descriptions/composable_node.py
	modified:   launch_ros/launch_ros/utilities/__init__.py
	new file:   launch_ros/launch_ros/utilities/lifecycle_event_manager.py
	modified:   test_launch_ros/test/test_launch_ros/actions/test_lifecycle_node.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   launch_ros/launch_ros/actions/load_composable_nodes.py
	both modified:   launch_ros/launch_ros/event_handlers/on_state_transition.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@christophebedard
Copy link
Member

Note: #449 is a follow-up fix to the PR that this backports, so it should be backported after this too.

@christophebedard
Copy link
Member

@emersonknapp since you requested this backport, would you be willing to fix the merge conflicts?

@emersonknapp
Copy link
Contributor

@christophebedard done!

@christophebedard
Copy link
Member

@Mergifyio rebase

SteveMacenski and others added 2 commits August 8, 2025 17:44
* autostarting lifecycle nodes and example

Signed-off-by: Steve Macenski <[email protected]>

* fix linting

Signed-off-by: Steve Macenski <[email protected]>

* fix linting

Signed-off-by: Steve Macenski <[email protected]>

* removing an unused variable

Signed-off-by: Steve Macenski <[email protected]>

* initializing a member client as none like sub

Signed-off-by: Steve Macenski <[email protected]>

* completing auto-start feature for composition nodes

Signed-off-by: Steve Macenski <[email protected]>

* linting

Signed-off-by: Steve Macenski <[email protected]>

* final linting fix

Signed-off-by: Steve Macenski <[email protected]>

* Resolving issue with StateTransition messages

Signed-off-by: Steve Macenski <[email protected]>

* removing Node's autostart

Signed-off-by: Steve Macenski <[email protected]>

* Fixing lifecyclenode type

Signed-off-by: Steve Macenski <[email protected]>

* update docstring

Signed-off-by: Steve Macenski <[email protected]>

* adding in composable lifecycle node

Signed-off-by: Steve Macenski <[email protected]>

* Adding docstring

Signed-off-by: Steve Macenski <[email protected]>

* require autostart non-None

Signed-off-by: Steve Macenski <[email protected]>

* remove unused imports

Signed-off-by: Steve Macenski <[email protected]>

* review comments continued

Signed-off-by: Steve Macenski <[email protected]>

* is lifecycle node and autostart to lifecycle-only classes

Signed-off-by: Steve Macenski <[email protected]>

* final bits

Signed-off-by: Steve Macenski <[email protected]>

* whoops, remove the Avatar-inspired printout

Signed-off-by: Steve Macenski <[email protected]>

* finish linting

Signed-off-by: Steve Macenski <[email protected]>

* review fix

Signed-off-by: Steve Macenski <[email protected]>

* remove old import

Signed-off-by: Steve Macenski <[email protected]>

---------

Signed-off-by: Steve Macenski <[email protected]>
(cherry picked from commit 3569f0d)

# Conflicts:
#	launch_ros/launch_ros/actions/load_composable_nodes.py
#	launch_ros/launch_ros/event_handlers/on_state_transition.py
Signed-off-by: Emerson Knapp <[email protected]>
@mergify
Copy link
Author

mergify bot commented Aug 8, 2025

rebase

✅ Branch has been successfully rebased

@christophebedard christophebedard force-pushed the mergify/bp/humble/pr-430 branch from 6613fc7 to 4ffc49c Compare August 8, 2025 17:44
@christophebedard
Copy link
Member

Pulls: #476
Gist: https://gist.githubusercontent.com/christophebedard/7a7fa64091a1902884e0cc5fd18b7e8d/raw/594011c5cb234e83c9d082ce107e21d7fb767e6a/ros2.repos
BUILD args: --packages-above-and-dependencies launch_ros test_launch_ros
TEST args: --packages-above launch_ros test_launch_ros
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/16687

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@christophebedard
Copy link
Member

@ros-pull-request-builder retest this please

*,
entities: SomeActionsType,
target_lifecycle_node: LifecycleNode = None,
entities: SomeEntitiesType,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't imported and it doesn't exist in Humble: https://github.com/ros2/launch/blob/rolling/launch/launch/some_entities_type.py

@emersonknapp emersonknapp changed the title Autostarting lifecycle nodes and example launch file demo (backport #430) [humble] Autostarting lifecycle nodes and example launch file demo (backport #430) Aug 28, 2025
@ahcorde
Copy link
Contributor

ahcorde commented Oct 6, 2025

what's the status of this PR @emersonknapp @christophebedard ?

@emersonknapp
Copy link
Contributor

Ah, sorry I've let it linger so long. There's a couple utilities that this diff depends on that aren't in this backport so it doesn't work right now. Requires just a bit of manual tweaking, should be easy but I haven't been able to get to it yet.

Maybe a priority in the next week or two, since I mention it briefly in my roscon talk 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants