rclcpp icon indicating copy to clipboard operation
rclcpp copied to clipboard

Custom allocators for Service/Clients

Open ihasdapie opened this issue 2 years ago • 0 comments

Feature request

Custom allocators for Service/Clients

Feature description

Currently the allocator for rclcpp services and clients cannot be configured by the user, though publishers and subscribers support this feature. This is useful for systems that implement a non-default allocator and would like to use ros2 services.

Implementation considerations

The implementation could mirror that of rclcpp publishers/subscribers where the create_publisher/create_subscriber functions are templated on an AllocatorT.

https://github.com/ros2/rclcpp/blob/b953bdddf8de213b4a051ecf2d668dad65ff9f89/rclcpp/include/rclcpp/create_publisher.hpp#L38-L52

Steps that would need to be taken would then be:

  1. Create an analogue of PublisherOptionsBase class for Services, i.e. ServiceOptionsBase.
  • Implement a ServiceOptionsWithAllocator which templates ServiceOptionsBase on an AllocatorT as per implementation with PublisherOptionsWithAllocator
  1. Update create_service.hpp to provide a rclcpp::create_service templated on an AllocatorT accepting a ServiceOptionsWithAllocator.
  2. Pass the service options containing the custom allocator to rcl_service_init
  3. Do the same with clients

It may also be good to copy the Factory design pattern used on the publisher/subscriber implementation for consistency.

Reference:

  • https://github.com/ros2/rclcpp/blob/rolling/rclcpp/include/rclcpp/allocator/allocator_common.hpp

ihasdapie avatar Aug 11 '22 20:08 ihasdapie