Skip to content

Support callback groups created after spin() #42

@atsushi421

Description

@atsushi421

Problem

Both CallbackIsolatedExecutor::spin() and ComponentManagerCallbackIsolated::add_node_to_executor() only discover callback groups at the time they are initially called. Any callback groups created after spin() has started (e.g., groups created lazily in timer callbacks or after initialization) are never detected and therefore never assigned dedicated executor threads.

Affected files

  • callback_isolated_executor/src/callback_isolated_executor.cppspin() iterates weak_groups_to_nodes_ and weak_nodes_ once at startup, spawns threads, then blocks on join(). Late-created groups are invisible.
  • callback_isolated_executor/src/component_container_callback_isolated.cppadd_node_to_executor() runs for_each_callback_group() once when a node is loaded. Groups created after this point are missed.

Proposed Solution

Implement a polling-based monitoring mechanism that periodically scans for newly created callback groups, similar to the approach taken in the agnocast repository:

Key design points (from the agnocast implementation)

  1. A configurable polling interval (default 100ms) via monitor_polling_interval_ms parameter
  2. Extracted thread-spawning logic into a reusable helper for consistent handling of both startup and dynamically-created groups
  3. rclcpp::ok() checks to prevent executor creation after context shutdown
  4. Proper thread lifecycle management (joining child threads during cleanup)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions