Skip to content
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

Expose subscription options #53

Closed
wants to merge 2 commits into from

Conversation

audrow
Copy link
Member

@audrow audrow commented Apr 28, 2021

This PR is needed for QoS overrides in subscriptions, as in ros-perception/image_pipeline#651.

Signed-off-by: Audrow Nash <[email protected]>
@audrow audrow added the enhancement New feature or request label Apr 28, 2021
@audrow audrow self-assigned this Apr 28, 2021
Comment on lines +64 to +65
rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> options =
rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>()) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could introduce these options without breaking API, but I'm not sure if that's possible in a pure virtual class.

To be honest, it's not clear to me why we have this abstract class to begin with, it doesn't appear to be used anywhere (besides being implemented by Subscriber below) 🤔 It might be safer to omit the changes to SubscriberBase and add new overloads to Subscriber to incorporate the subscriber options.

Pinging @mjcarroll for thoughts (I think you're the maintainer?).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way to avoid breaking API is to keep the old

  virtual void subscribe(
    rclcpp::Node::SharedPtr node,
    const std::string& topic,
    const rmw_qos_profile_t qos = rmw_qos_profile_default) = 0;

and add a new

  virtual void subscribe(
    rclcpp::Node::SharedPtr node,
    const std::string& topic,
    const rmw_qos_profile_t qos,
    rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> options)
  {
    (void)options;
    // --> warn about method not overriden here <--
    this->subscribe(node, topic, qos);
  };

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, it's not clear to me why we have this abstract class to begin with

It doesn't seem to be meant to be extended by external users, so it might be ok to just add new virtual methods to it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not meant to be extended, then I think we could just add the new method to the concrete class.

We could go so far as to deprecate the pure virtual class and/or remove it in a separate PR, to avoid similar API/ABI issues in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also okay with your proposal to implement and warn about the non-overridden method #53 (comment)

Signed-off-by: Audrow Nash <[email protected]>
@@ -43,6 +43,7 @@
namespace message_filters
{

template <typename AllocatorT=std::allocator<void>>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that making this virtual class templated makes much sense, I would just use rclcpp::SubscriptionOptions below

Comment on lines +64 to +65
rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> options =
rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>()) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way to avoid breaking API is to keep the old

  virtual void subscribe(
    rclcpp::Node::SharedPtr node,
    const std::string& topic,
    const rmw_qos_profile_t qos = rmw_qos_profile_default) = 0;

and add a new

  virtual void subscribe(
    rclcpp::Node::SharedPtr node,
    const std::string& topic,
    const rmw_qos_profile_t qos,
    rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> options)
  {
    (void)options;
    // --> warn about method not overriden here <--
    this->subscribe(node, topic, qos);
  };

Comment on lines +64 to +65
rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> options =
rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>()) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, it's not clear to me why we have this abstract class to begin with

It doesn't seem to be meant to be extended by external users, so it might be ok to just add new virtual methods to it.

@audrow
Copy link
Member Author

audrow commented May 18, 2021

Closed in favor of #56.

@audrow audrow closed this May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants