-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rosbag2_cpp Writer zero copy msg #1491
Comments
(just a note) for subscription (in case of rosbag2, recorder), (to answer your question) with quick code scan, i do not think CC: @MichaelOrlov btw, there has been discussion about |
@HRXWEB It doesn't make sense to have writer API with LoanedMessages because we will have to make a copy of the message eventually before we will store it in the storage file or database anyway. The main advantages of using LoanedMessages are avoiding extra copies and enabling zero-copy like messages transfer over the shared memory. In the case of the data recording, we are operating with the
We are getting from subscription callback the rosbag2/rosbag2_cpp/src/rosbag2_cpp/writer.cpp Lines 180 to 201 in aa8cc02
i.e. there are no actual data copies from the subscription to the further layers of the rosbag2 down until we need to really story serialized data to the file of database on the concrete rosbag2_storage_plugin implementation.
As you can see the data path in the rosbag2 is already optimized in such a way that there wouldn't be any differences if it would be LoanedMessage or regular shared_pointer to the rclcpp::SerializedMessage from a generic subscription. Moreover, since we are getting As regards the rosbag2 player. We do support publishing with loaned messages if publishers support loaned messages rosbag2/rosbag2_transport/src/rosbag2_transport/player.cpp Lines 216 to 227 in aa8cc02
for reference. However, there are some caveats there as well. We have to deserialize the message if we need to publish it with a loaned message interface. Contrary to it. In the regular flow, we can transfer serialized message data from storage directly up to the transport layer without deserialization. Using loaned messages during playback may be beneficial if playing back on the same ECU as other consuming nodes and when messages will be delivered over shared memory transport. And if there is more than one consumer on the topic. i.e. we will deserialize the message once in the rosbag2 player and consumers will get pointers to this data over the shared memory transport. cc: @fujitatomoya |
Thank you very much for your professional response. I understood some parts of what you mentioned, but I still have some confusion regarding the question I previously raised. I would like to provide a more detailed description of my requirements: I want to create a ROS2 bag by reading from files. I understand that during play bag, there will be a Thank you for your assistance. |
Hi @HRXWEB I am not sure that I correctly understand your question
The |
according to the current code, rosbag2 player can support as @MichaelOrlov pointed out, this will try to use about zero copy support, it just depends on the RMW implementation. after borrowing memory from the middleware, it is up to the middleware feature to support zero copy data sharing or not. (e.g https://fast-dds.docs.eprosima.com/en/latest/fastdds/transport/datasharing.html) after all, that is beneficial in performance to use |
thanks so much, I get the important info .. tabs:: .. group-tab:: Linux
and, about the ROS_DISABLE_LOANED_MESSAGES, Is it right that when it set , if I use the borrow_loaned_message api to fill data and send msg is allowed,and zero copy is worked well ? and, about the sharedprt thing, I used to think the loaned_msg will be keeped by subscriber until the sharedptr distoryed.obviorsly,I am wrong. I will learn it in the future, thanks again |
|
Description
Hello, I would like to inquire whether the
Writer
in rosbag2_cpp supports creating a bag by reading files and if it also supports the LoanedMessage type of msg. I am interested in using the LoanedMessage type for my specific use case. Could you please provide information on the current support for this feature?Thanks in advance
The text was updated successfully, but these errors were encountered: