ros2 / ros2/rclcpp

Custom allocators for Service/Clients

Open
#1,989 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog
Dominant language
C++
Stars
805
Forks
564
Avg merge
1d 17h
Merged PRs (30d)
27

Description

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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the allocator-aware publisher and subscriber implementation in create_publisher.hpp and allocator_common.hpp. Then inspect publisher_options.hpp and create_service.hpp to map the proposed ServiceOptionsBase and ServiceOptionsWithAllocator design, followed by the corresponding client code. Done means services and clients accept custom allocator options and pass them to rcl_service_init.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.