Skip to content

Commit

Permalink
Merge pull request ros2#11 from mauropasse/mauro-irobot/add-events-ex…
Browse files Browse the repository at this point in the history
…ecutor

Support events
  • Loading branch information
iRobot ROS committed Oct 13, 2020
2 parents 427e17c + 652ccf8 commit ab92918
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions rclcpp/include/rclcpp/qos_event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename
rclcpp::function_traits::function_traits<EventCallbackT>::template argument_type<0>>::type;
Expand Down
2 changes: 1 addition & 1 deletion rclcpp/src/rclcpp/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
2 changes: 1 addition & 1 deletion rclcpp/src/rclcpp/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
2 changes: 1 addition & 1 deletion rclcpp/src/rclcpp/subscription_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

0 comments on commit ab92918

Please sign in to comment.