ros2 / rmw_cyclonedds

ROS 2 RMW layer for Eclipse Cyclone DDS
Apache License 2.0
117 stars 90 forks source link

Is there a way to obtain the address of shared memory at init phase ? #514

Closed lix19937 closed 1 month ago

lix19937 commented 2 months ago

The loan API allows for true zero-copy transfer by directly consctructing the message data in Shared Memory. To do so, we first have to loan this Shared Memory chunk explicitly.

// init phase 
std::set<void *> ptr_set;

// in callback phase at runtime  
auto loaned_msg = pub_->borrow_loaned_message();
loaned_msg.get().data = count_++;
pub_->publish(std::move(loaned_msg));
ptr_set.insert(&(loaned_msg.get().data));

I found ptr_set.size() = N // N is a const number

fujitatomoya commented 1 month ago

@lix19937 can you close this issue? this is more like a question, please consider to post this kind of question to https://robotics.stackexchange.com/ where is the centralized QA site. it is likely that you can get the feedback against the questions from community.

lix19937 commented 1 month ago

OK, thanks @fujitatomoya