-
Notifications
You must be signed in to change notification settings - Fork 44
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
[rclc/rclc_executor]: subscribe loaned message #394
Comments
@Zard-C thanks for proposing to use loaned messages also in rclc. Out of my head, I have no explanation, why it failed to return the message. We would have to check the implementation of the return-method in RMW layer. Typically, I would use loaned-messages for pipelined processing, e.g. to pass the message data to multiple callbacks or threads without the need to copy the data (as the scope of the message data is not limited to the subscription callback). What is your use-case for loaned messages? |
@JanStaschulat Thanks Jan, before trying to use loaned message with rclc, I took a look at rclcpp::executor's implementation(code here), it shows where and when to take and return loaned message. After checking my codes and steps to generate that error, I found out that the By the way, my use-case of loaned message is: Publish and subscribe a large but fixed(bounded) message in different nodes, a fixed picture generated by a camera, which may up to Mbytes. I believed that using loaned message would reduce data copying. |
@Zard-C several things i would like to share with you for what you are trying to do here.
to see those conditions, we have interface to check if these are called in be advised that using loaned interfaces are tricky, this is all because of the memory ownership. i want to point out above constraint. this says, once the message is returned via further more, loaned interfaces are the memory management between ROS 2 and RMW implementation endpoints. it does not say it achieve the zero copy between the endpoints underneath implementation. if your final target is to support zero copy data sharing, you need to enable RMW implementation data sharing feature. you can see more details for https://github.com/ros2/rmw_fastrtps#enable-zero-copy-data-sharing. i hope this helps some, if you have any questions, let me know. I am positive for this feature enabled in |
Background
When I was writting example codes that using loaned message with
rclc
interfaces (pub/sub) , the publish_with_loaned_msg demo works fine, but then I found out that there's no such implementation in rclc_executor which allow executor to take loaned subscription message from rmw. So I added some codes toexecutor.c
:It works with my test code subscription_with_loaned_message
Discussion
The draft usedThis is because I used anotherrcl_take_loaned_message
to take loaned msg from rmw, the question is, when and where to return it to rmw? I tried to return in sub callback, unfortunately, the return value wasRCL_RET_ERROR
librclc.so
, a big mistake for me. 😇Thanks in advance!
The text was updated successfully, but these errors were encountered: