Skip to content

Comments

[DRAFT] GenericSubscription support in IntraProcessManager#3083

Draft
roncapat wants to merge 1 commit intoros2:rollingfrom
roncapat:rolling_ipc_gen
Draft

[DRAFT] GenericSubscription support in IntraProcessManager#3083
roncapat wants to merge 1 commit intoros2:rollingfrom
roncapat:rolling_ipc_gen

Conversation

@roncapat
Copy link
Contributor

Description

GenericSubscription is extensively used by rosbag2. However, this means that currently, intra-process communication is not leveraged. Even when composing rosbag2::Recorder, topics are subscribed in the traditional way - IntraProcessManager does not handle the data exchange towards the recorder's subscribers, as the GenericSubscrition does not register itself as capable of intra-process comms (no SubscriptionIntraProcess is created).

Of course, at some point serialization needs to happen. So there will always some cost in using a GenericSubscription. This gets even more valid when dealing with rosbag2, that currently stores data in serialized format. The point here is to avoid RMW / data transmission on loopback when not needed.

This PR allows GenericSubscription to create a SubscriptionIntraProcess whose template type is rclcpp::SerializedMessage. IntraProcessManager gets new internal collections and methods specifically used to track and manage these new subscribers - instead of mixing them in existing structures, they are collected in separate collections so that the added logic can easily treat normal subscribers and generic subscribers in different ways (if needed).

See ros2/rosbag2#2267 for motivation & further context.

Is this user-facing behavior change?

No outstanding changes in API - in theory stuff like rosbag2 needs just to be rebuilt against this branch of rclcpp. Everything happens "under the hood" in the constructor of GenericSubscrition and the IntraProcessManager.

Did you use Generative AI?

No

Additional Information

  • Still WIP - next step is to build rosbag2 on top of this.
  • test_generic_pubsub has been modified to run with intra-process enabled and two additional test cases. It runs green!

Feel free to provide your feedbacks on this - I'll may let sink this here for a while before polishing in greater detail.

…anager

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>
@mcp-ats
Copy link

mcp-ats commented Feb 24, 2026

@roncapat great you started the draft, I will give it a better look ASAP.

From a first look I see that it uses a callback with rclcpp::SerializedMessage but the issue is that this would require to receive serialized messages, therefore we miss the IPC requirements.
To my understanding, the subscription must happen with shared_ptr or unique_ptr for IPC and therefore serialization should happen within the callback to be written to a bag.

With IPC, smart pointers are passed and no serialization takes place.

Thank you for setting up the draft, I will give it a try and have a look as soon as I can.

@roncapat
Copy link
Contributor Author

Hi @mcp-ats , thanks for the feedback!

Yes, this patch favours serialization during publishing - before adding the messages to the buffers. Still, this should be partially beneficial.

At some point, you will need to serialize anyway. This patch helps serializing just one time even in presence of multiple GenericSubscriber.

We may figure out what may be a draft implementation that serializes on the subscription side.

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.

2 participants