Event handling on ROS2 Nodes across Launch files
I am using ROS2 Galactic, and writing Python Launch files.
Let’s say I have a launch file, L1 that starts node L1N1.
Then I have another launch file, L2, that can start node L2N1 on a specific condition.
The way I am running these Launch files is, that I am including the launch description of L1 into L2, this means that L2 starts running L2N1, and now I want to condition the execution of my node L2N2, on the basis of the state of L1N1.
Is there a way to register an event handler on the state of node L1N1, executed by the launch file L1, that was included inside the same launch file L2?
Its difficult to answer this question without knowing exactly what part of your L2N2 node you are trying to condition (the launch itself, its parameters, its arguments, etc) as well what "state" you are conditioning against from L1N1 (lifecycle state, launch/not launched, a publication, etc.)
Can you share the launch files or add more detail?
Ok so here's what I want to do, in Pseudo code.
This is the launch file L2:
Run node L2N1.
Include the Launch Description of L1.
IF(lifecycleState(L1N1) == 'active'): Run L2N2.
Return the generated launch description of L2, to be launched later.