Skip to content

feat(lifecycle): implement ROS 2 managed node lifecycle#121

Open
YuanYuYuan wants to merge 13 commits intomainfrom
dev/lifecycle
Open

feat(lifecycle): implement ROS 2 managed node lifecycle#121
YuanYuYuan wants to merge 13 commits intomainfrom
dev/lifecycle

Conversation

@YuanYuYuan
Copy link
Collaborator

Summary

Implements the ROS 2 managed node lifecycle as defined in REP-2006. Lifecycle nodes expose explicit state transitions (configure, activate, deactivate, cleanup, shutdown) so system orchestrators can safely sequence bringup and teardown of complex robot software.

Key Changes

  • ZLifecycleNode: full 4-state / 7-transition state machine with configurable callbacks (on_configure, on_activate, on_deactivate, on_cleanup, on_shutdown, on_error)
  • ZLifecyclePublisher: gated publisher that silently drops messages when the node is not Active; registered publishers activate/deactivate in bulk with the node
  • 5 lifecycle management services (~/change_state, ~/get_state, ~/get_available_states, ~/get_available_transitions, ~/get_transition_graph) and ~/transition_event topic — compatible with ros2 lifecycle CLI
  • Inline wire types in lifecycle/msgs.rs to avoid circular dependency with ros-z-msgs
  • lifecycle_msgs .msg/.srv assets added to codegen and always generated (alongside builtin_interfaces)
  • 17 integration tests covering state transitions, callback return values, publisher gating, bulk activate/deactivate, and late publisher registration
  • lifecycle_talker example and book chapter under Core Concepts
  • check-local.nu: build step now includes --examples to catch example compilation regressions

Breaking Changes

None

… machine

- ZLifecycleNode with full 4-state / 7-transition ROS 2 state machine
- 5 lifecycle management services (change_state, get_state,
  get_available_states, get_available_transitions, get_transition_graph)
- ~/transition_event publisher on every state change
- ZLifecyclePublisher: gated publisher that silently drops when inactive,
  warns once per deactivation cycle
- ManagedEntity trait for bulk activate/deactivate of publishers
- Inline lifecycle wire types in lifecycle/msgs.rs to avoid circular dep
  with ros-z-msgs
- create_publisher() immediately activates if node is already Active
Tests cover state machine transitions, callback return values (Success,
Failure, Error), publisher gating, bulk activate/deactivate, and late
publisher registration. Example demonstrates the full configure →
activate → publish → deactivate → shutdown flow.
- New book chapter covering state machine diagram, all transitions,
  callbacks, lifecycle publishers, CLI interface, and all 5 services
- Wired into SUMMARY.md under Core Concepts
- check-local.nu: build now includes --examples to catch example
  compilation errors
- check-local.nu: fix Nushell parse error in plural summary message
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://ZettaScaleLabs.github.io/ros-z/pr-preview/pr-121/

Built to branch gh-pages at 2026-03-05 08:09 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Replace PID-derived port allocation with TcpListener::bind("0") so the
OS picks a guaranteed-free port. PID % 10000 caused collisions when
multiple test binaries ran in parallel on the same CI runner.
Async client wrapping the four lifecycle management services
(change_state, get_state, get_available_states,
get_available_transitions). Provides high-level helpers for
configure/activate/deactivate/cleanup/shutdown transitions
and a low-level trigger() for arbitrary TransitionId values.
…ook docs

- 7 new integration tests for ZLifecycleClient (get_state, full cycle,
  shutdown, available states/transitions, invalid transition)
- 1 new test for disable_communication_interface
- lifecycle_bringup example showing orchestrator pattern
- Book chapter section on ZLifecycleClient with code snippets
…lake

The test was publishing only 10 messages at 100ms intervals (1s total)
while schema discovery via create_dyn_sub_auto can take several seconds
under CI load. Switch to a cancellable loop that publishes until the
subscriber has received what it needs, matching the pattern used in the
other type_description tests.
Replaces fixed 2s sleep with a 15s retry loop so the test does not
fail when the server takes longer than expected to register its
queryable (observed on kilted under CI load).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant