Launch Event Handlers and Ordered Startup¶
Source: ros2-copilot-skills event handlers skill
Why This Matters¶
Not every ROS 2 system can be launched as a flat list of nodes. Some robots need ordered bringup, crash reactions, process cleanup, or dynamic launch decisions based on what has already happened. Launch event handlers exist for that layer of orchestration.
Distilled Takeaways¶
- Event handlers let launch descriptions respond to process start, exit, shutdown, timer, and other runtime events.
- Ordered startup is sometimes necessary, but it should be justified and explicit rather than hidden in arbitrary sleeps.
- Cleanup and graceful degradation are part of launch design, not postmortem scripts.
OpaqueFunctionis powerful but should be used to clarify dynamic logic, not to hide all structure in Python.- Event-driven launch logic is often the right place to encode operational assumptions about the robot.
Practical Guidance¶
- Prefer explicit event chains over “sleep 5 seconds and hope.”
- Make restart behavior deliberate rather than accidental.
- Use launch orchestration to support, not replace, robust node design.
- Keep launch logic readable enough that operators can understand what the system will do on failure.
Corroborating References¶
When to Read the Original Source¶
Go to the original skill when you want concrete OnProcessStart, OnProcessExit, OnShutdown, timer, restart, and ordered-startup patterns in launch Python.