hello，everyone，i saw create_generic_publisher is still exist but it is rarely used in many places, and I am wondering if it is possible to completely remove it by using create_publisher replace it？
I see 4.7k hits on github for a search of this function (not all exact uses, but still). Personally I don’t see a clear need or benefit to removing it.
But it is rarely referenced in the source code of ROS2 and Autoware。
@Autostone-c i am not really sure why you are asking this removal, but hopefully the following can answer your question.
We do use
that is required to support
ros2 bag play, that is one of the cases for publisher for serialized messages whose type is not known at compile time.
create_generic_publisher is still exist but it is rarely used in many places, and I am wondering if it is possible to completely remove it by using create_publisher replace it？
the capability that
create_generic_publisher brings to user application is different from templated
@Autostone-c As @tomoyafujita mentioned above we are using it in the rosbag2.
This is the main place where we use it and I believe this API was originally created to facilitate rosbag2 needs and capabilities to be able to publish recorded messages in already serialized form to avoid extra performance burden on deserialization and again serialization on the transport layer.
Without it you need to compile large swathes of templated C++ code to support a large number of messages.
I had a library that had subscribers/publisher code for around 500 different message types and the library blows up to nearly a gigabyte. I changed it to generic pub/sub and it dropped to around 5mb.
We are also using both generic_publisher and generic_subscriber in our Godot Engine-based ROS2 simulator. As others already wrote: it is designed for use cases where you don’t necessarily know the type of messages that you need to handle at build time.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.