Skip to content

Commit

Permalink
Merge pull request #21 from mauropasse/mauro/add-events-executor-with…
Browse files Browse the repository at this point in the history
…-actions-support

Add APIs to support actions on EventsExecutor
  • Loading branch information
iRobot ROS authored Jul 14, 2021
2 parents dc6abbd + 9a92d03 commit 25f0bf1
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 0 deletions.
41 changes: 41 additions & 0 deletions rcl_action/include/rcl_action/action_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern "C"

#include "rcl_action/types.h"
#include "rcl_action/visibility_control.h"
#include "rcl/event_callback.h"
#include "rcl/macros.h"
#include "rcl/node.h"

Expand Down Expand Up @@ -741,6 +742,46 @@ bool
rcl_action_client_is_valid(
const rcl_action_client_t * action_client);

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_client_set_goal_client_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data);

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_client_set_cancel_client_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data);

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_client_set_result_client_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data);

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_client_set_feedback_subscription_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data);

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_client_set_status_subscription_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data);

#ifdef __cplusplus
}
#endif
Expand Down
25 changes: 25 additions & 0 deletions rcl_action/include/rcl_action/action_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extern "C"
#include "rcl_action/goal_handle.h"
#include "rcl_action/types.h"
#include "rcl_action/visibility_control.h"
#include "rcl/event_callback.h"
#include "rcl/macros.h"
#include "rcl/node.h"
#include "rcl/time.h"
Expand Down Expand Up @@ -930,6 +931,30 @@ RCL_WARN_UNUSED
bool
rcl_action_server_is_valid_except_context(const rcl_action_server_t * action_server);

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_server_set_goal_service_callback(
const rcl_action_server_t * action_server,
rcl_event_callback_t callback,
const void * user_data);

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_server_set_cancel_service_callback(
const rcl_action_server_t * action_server,
rcl_event_callback_t callback,
const void * user_data);

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_server_set_result_service_callback(
const rcl_action_server_t * action_server,
rcl_event_callback_t callback,
const void * user_data);

#ifdef __cplusplus
}
#endif
Expand Down
80 changes: 80 additions & 0 deletions rcl_action/src/rcl_action/action_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,86 @@ rcl_action_client_wait_set_get_entities_ready(
return RCL_RET_OK;
}

rcl_ret_t
rcl_action_client_set_goal_client_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data)
{
if (!rcl_action_client_is_valid(action_client)) {
return RCL_RET_ACTION_CLIENT_INVALID;
}

return rcl_client_set_on_new_response_callback(
&action_client->impl->goal_client,
callback,
user_data);
}

rcl_ret_t
rcl_action_client_set_cancel_client_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data)
{
if (!rcl_action_client_is_valid(action_client)) {
return RCL_RET_ACTION_CLIENT_INVALID;
}

return rcl_client_set_on_new_response_callback(
&action_client->impl->cancel_client,
callback,
user_data);
}

rcl_ret_t
rcl_action_client_set_result_client_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data)
{
if (!rcl_action_client_is_valid(action_client)) {
return RCL_RET_ACTION_CLIENT_INVALID;
}

return rcl_client_set_on_new_response_callback(
&action_client->impl->result_client,
callback,
user_data);
}

rcl_ret_t
rcl_action_client_set_feedback_subscription_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data)
{
if (!rcl_action_client_is_valid(action_client)) {
return RCL_RET_ACTION_CLIENT_INVALID;
}

return rcl_subscription_set_on_new_message_callback(
&action_client->impl->feedback_subscription,
callback,
user_data);
}

rcl_ret_t
rcl_action_client_set_status_subscription_callback(
const rcl_action_client_t * action_client,
rcl_event_callback_t callback,
const void * user_data)
{
if (!rcl_action_client_is_valid(action_client)) {
return RCL_RET_ACTION_CLIENT_INVALID;
}

return rcl_subscription_set_on_new_message_callback(
&action_client->impl->status_subscription,
callback,
user_data);
}

#ifdef __cplusplus
}
#endif
54 changes: 54 additions & 0 deletions rcl_action/src/rcl_action/action_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,60 @@ rcl_action_server_wait_set_get_entities_ready(
return RCL_RET_OK;
}

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_server_set_goal_service_callback(
const rcl_action_server_t * action_server,
rcl_event_callback_t callback,
const void * user_data)
{
if (!rcl_action_server_is_valid_except_context(action_server)) {
return RCL_RET_ACTION_SERVER_INVALID;
}

return rcl_service_set_on_new_request_callback(
&action_server->impl->goal_service,
callback,
user_data);
}

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_server_set_result_service_callback(
const rcl_action_server_t * action_server,
rcl_event_callback_t callback,
const void * user_data)
{
if (!rcl_action_server_is_valid_except_context(action_server)) {
return RCL_RET_ACTION_SERVER_INVALID;
}

return rcl_service_set_on_new_request_callback(
&action_server->impl->result_service,
callback,
user_data);
}

RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_action_server_set_cancel_service_callback(
const rcl_action_server_t * action_server,
rcl_event_callback_t callback,
const void * user_data)
{
if (!rcl_action_server_is_valid_except_context(action_server)) {
return RCL_RET_ACTION_SERVER_INVALID;
}

return rcl_service_set_on_new_request_callback(
&action_server->impl->cancel_service,
callback,
user_data);
}

#ifdef __cplusplus
}
#endif

0 comments on commit 25f0bf1

Please sign in to comment.