Make sick safetyscanners2 compatible with composition #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
The current driver does not support zero-copy intra-process communication (IPC) when used as a composed component.
This pull request introduces the required modifications to enable composition-friendly, zero-copy operation.
Key Changes
Constructor Signature
The primary constructor now accepts rclcpp::NodeOptions, ensuring the driver can be instantiated as a composable node.
Component Registration
The node is registered with rclcpp_components_register_node, allowing it to be loaded dynamically into a component container.
Subscriber Count Check
Before each publish, the driver verifies that at least one subscriber is connected, eliminating unnecessary work when no consumers are present.
Zero-Copy Publishing
Message data are created and published as std::unique_ptr objects.
In environments where IPC is enabled, this enables true zero-copy transfer; when IPC is disabled, behavior remains identical to standard publishing.
Reduced Copy Overhead
Internal data structures are generated directly into unique_ptr instances, minimizing intermediate copies and improving performance.
Maintainer Guidance
These changes, particularly the revised constructor, introduce breaking API differences.
If the new interface or zero-copy assumptions conflict with the project’s roadmap, please let me know. I will close this PR rather than disrupt the main branch.