Skip to content

Conversation

@atsushi421
Copy link
Collaborator

@atsushi421 atsushi421 commented Dec 24, 2025

Description

This PR adds a new spawn_cie_thread function that enables thread scheduling management for non-ROS2 worker threads. The function automatically creates an isolated rclcpp context within each spawned thread, allowing threads to publish their information to the CIE thread configurator without requiring the caller to provide a ROS node.

Key Changes

  • New Message Type: Introduced NonRosThreadInfo.msg to distinguish non-ROS worker threads from ROS callback groups
  • Unified Thread Management: Refactored internal structures to use a common ThreadConfig for both ROS callback groups and non-ROS threads
  • YAML Configuration: Extended the YAML configuration format to include a non_ros_threads section alongside callback_groups

Related links

How was this PR tested?

  • sample application
callback_groups:
  - id: /sample_space/sample_subspace/sample_node@Subscription(/parameter_events)@Service(/sample_space/sample_subspace/sample_node/get_parameters)@Service(/sample_space/sample_subspace/sample_node/get_parameter_types)@Service(/sample_space/sample_subspace/sample_node/set_parameters)@Service(/sample_space/sample_subspace/sample_node/set_parameters_atomically)@Service(/sample_space/sample_subspace/sample_node/describe_parameters)@Service(/sample_space/sample_subspace/sample_node/list_parameters)
    affinity: ~
    policy: SCHED_OTHER
    priority: 0

  - id: /sample_space/sample_subspace/sample_node@Subscription(/sample_space/sample_subspace/topic_in)
    affinity: ~
    policy: SCHED_OTHER
    priority: 0

  - id: /sample_space/sample_subspace/sample_node@Timer(1333000000)
    affinity: ~
    policy: SCHED_OTHER
    priority: 0

  - id: /sample_space/sample_subspace/sample_node@Timer(3000000000)
    affinity: ~
    policy: SCHED_OTHER
    priority: 0

non_ros_threads:
  - id: sample_non_ros_thread
    affinity: ~
    policy: SCHED_OTHER
    priority: 0

  - id: standalone_worker
    affinity: ~
    policy: SCHED_OTHER
    priority: 0

Notes for reviewers

…lated rclcpp context

Remove node dependency from spawn_cie_thread function and create an isolated
rclcpp context within each spawned thread. This change allows threads to be
spawned without requiring the caller to manage ROS node dependencies, while
maintaining callback group registration capabilities through autonomous context
initialization and shutdown.

The implementation:
- Initializes a dedicated rclcpp Context with auto logging disabled
- Creates a temporary node for publishing callback group information
- Properly shuts down the context after publishing
- Executes the user-provided function with forwarded arguments
- Simplifies the API by removing node parameter requirements

Update sample application to demonstrate usage with a non-ROS worker thread
that leverages the simplified spawn_cie_thread API.
@atsushi421 atsushi421 changed the title refactor(cie_thread_configurator): simplify spawn_cie_thread with isolated rclcpp context feat(cie_thread_configurator): spawn_cie_thread for non-ros2 thread Dec 24, 2025
@atsushi421 atsushi421 marked this pull request as draft December 24, 2025 03:54
@atsushi421 atsushi421 requested a review from Copilot December 24, 2025 04:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new spawn_cie_thread function that enables thread scheduling management for non-ROS2 worker threads by automatically creating an isolated rclcpp context within each spawned thread, eliminating the need for callers to provide a ROS node.

Key Changes:

  • Added templated spawn_cie_thread function to spawn threads with automatic CIE thread configurator integration
  • Created sample non-ROS process demonstrating standalone thread spawning
  • Integrated spawn_cie_thread into existing sample node to demonstrate usage within ROS2 components

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cie_thread_configurator/include/cie_thread_configurator/cie_thread_configurator.hpp Adds spawn_cie_thread template function with isolated rclcpp context creation
cie_sample_application/src/sample_non_ros_process.cpp New sample demonstrating standalone non-ROS thread spawning
cie_sample_application/src/sample_node.cpp Integrates spawn_cie_thread to spawn a non-ROS worker thread within the node
cie_sample_application/include/cie_sample_application/sample_node.hpp Adds destructor and non-ROS thread member to SampleNode class
cie_sample_application/package.xml Adds cie_thread_configurator dependency
cie_sample_application/CMakeLists.txt Updates build configuration for cie_thread_configurator dependency and new executable

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atsushi421 atsushi421 marked this pull request as ready for review December 24, 2025 04:25
@atsushi421 atsushi421 requested a review from sykwer December 24, 2025 04:25
@atsushi421 atsushi421 requested a review from Copilot December 24, 2025 09:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atsushi421 atsushi421 marked this pull request as ready for review December 24, 2025 10:13
@sykwer
Copy link
Member

sykwer commented Dec 26, 2025

better?
spawn_cie_thread -> spawn_ non_ros2_thread or spawn_non_ros2_thread_under_cie

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.

3 participants