Skip to content

create subscriber with message memory strategy #98

Open
@Derekglk

Description

@Derekglk

Hello,

My ROS2 node subscribes to two topics (left_image and right_image), and has a message filter (sync_exact policy) to get sychronized data.

Now I'm working on a custom memory allocator (following this tutorial), and in this example an rclcpp::message_memory_strategy has to be specified when creating the node subsription.

rclcpp::SubscriptionOptionsWithAllocator<Alloc> subscription_options;
auto msg_mem_strat = std::make_shared<rclcpp::message_memory_strategy::MessageMemoryStrategy<
       std_msgs::msg::UInt32, Alloc>>(alloc);
auto subscriber = node->create_subscription<std_msgs::msg::UInt32>(
       "allocator_tutorial", 10, callback, subscription_options, msg_mem_strat);

However I can't find a constructor in message_filters::Subscriber which takes message memory strategy as input.
This is what I have right now, and should be changed to using custom memory allocator.

message_filters::Subscriber<sensor_msgs::msg::Image> left_img;  
message_filters::Subscriber<sensor_msgs::msg::Image> right_img;   
std::shared_ptr<message_filters::Synchronizer<exact_policy>> syncExact;
left_img.subscribe(this, left_topic, custom_qos_profile);
right_img.subscribe(this, right_topic, custom_qos_profile);
syncExact = std::make_shared<message_filters::Synchronizer<exact_policy>>(exact_policy(10), left_img, right_img);  
syncExact->registerCallback(exact_sync_callback);

Am I following the right approach? How to specify the message memory strategy when using message filter?

Thank you very much!

Best Regards.

Derek

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions