diff --git a/rclcpp/include/rclcpp/qos_event.hpp b/rclcpp/include/rclcpp/qos_event.hpp index 0bce0aac37..58bfa0331d 100644 --- a/rclcpp/include/rclcpp/qos_event.hpp +++ b/rclcpp/include/rclcpp/qos_event.hpp @@ -148,6 +148,25 @@ class QOSEventHandler : public QOSEventHandlerBase event_callback_(callback_info); } + /// Set EventsExecutor's callback + RCLCPP_PUBLIC + void + set_events_executor_callback( + void * executor_context, + ExecutorEventCallback executor_callback) const override + { + rcl_ret_t ret = rcl_event_set_events_executor_callback( + executor_context, + executor_callback, + this, + &event_handle_, + false /* Discard previous events */); + + if (RCL_RET_OK != ret) { + throw std::runtime_error("Couldn't set EventsExecutor's callback to event"); + } + } + private: using EventCallbackInfoT = typename std::remove_reference::template argument_type<0>>::type; diff --git a/rclcpp/src/rclcpp/client.cpp b/rclcpp/src/rclcpp/client.cpp index 905b5fdbba..4f8604ed90 100644 --- a/rclcpp/src/rclcpp/client.cpp +++ b/rclcpp/src/rclcpp/client.cpp @@ -211,6 +211,6 @@ ClientBase::set_events_executor_callback( client_handle_.get()); if (RCL_RET_OK != ret) { - throw std::runtime_error(std::string("Couldn't set client callback")); + throw std::runtime_error("Couldn't set the EventsExecutor's callback to client"); } } diff --git a/rclcpp/src/rclcpp/service.cpp b/rclcpp/src/rclcpp/service.cpp index ee2865f067..914582e4ed 100644 --- a/rclcpp/src/rclcpp/service.cpp +++ b/rclcpp/src/rclcpp/service.cpp @@ -97,6 +97,6 @@ ServiceBase::set_events_executor_callback( service_handle_.get()); if (RCL_RET_OK != ret) { - throw std::runtime_error(std::string("Couldn't set service callback")); + throw std::runtime_error("Couldn't set the EventsExecutor's callback to service"); } } diff --git a/rclcpp/src/rclcpp/subscription_base.cpp b/rclcpp/src/rclcpp/subscription_base.cpp index e163f32c0a..345bbf7181 100644 --- a/rclcpp/src/rclcpp/subscription_base.cpp +++ b/rclcpp/src/rclcpp/subscription_base.cpp @@ -301,6 +301,6 @@ SubscriptionBase::set_events_executor_callback( subscription_handle_.get()); if (RCL_RET_OK != ret) { - throw std::runtime_error(std::string("Couldn't set subscription callback")); + throw std::runtime_error("Couldn't set the EventsExecutor's callback to subscription"); } }