Skip to content

Commit

Permalink
escalate RCL_RET_ACTION_xxx to 40XX. (#1191)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoya Fujita <[email protected]>
  • Loading branch information
fujitatomoya committed Sep 24, 2024
1 parent 3762d86 commit 1e565d5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
20 changes: 19 additions & 1 deletion rcl/include/rcl/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,26 @@ typedef rmw_ret_t rcl_ret_t;
#define RCL_RET_LIFECYCLE_STATE_NOT_REGISTERED 3001

// rcl action specific ret codes in 40XX
/// Action name does not pass validation return code.
#define RCL_RET_ACTION_NAME_INVALID 4000
/// No terminal timestamp for the goal as it has not reached a terminal state.
#define RCL_ACTION_RET_NOT_TERMINATED_YET 4001
#define RCL_RET_ACTION_NOT_TERMINATED_YET 4001
/// Action goal accepted return code.
#define RCL_RET_ACTION_GOAL_ACCEPTED 4100
/// Action goal rejected return code.
#define RCL_RET_ACTION_GOAL_REJECTED 4101
/// Action client is invalid return code.
#define RCL_RET_ACTION_CLIENT_INVALID 4102
/// Action client failed to take response return code.
#define RCL_RET_ACTION_CLIENT_TAKE_FAILED 4103
/// Action server is invalid return code.
#define RCL_RET_ACTION_SERVER_INVALID 4200
/// Action server failed to take request return code.
#define RCL_RET_ACTION_SERVER_TAKE_FAILED 4201
/// Action goal handle invalid return code.
#define RCL_RET_ACTION_GOAL_HANDLE_INVALID 4300
/// Action invalid event return code.
#define RCL_RET_ACTION_GOAL_EVENT_INVALID 4301

/// typedef for rmw_serialized_message_t;
typedef rmw_serialized_message_t rcl_serialized_message_t;
Expand Down
20 changes: 0 additions & 20 deletions rcl_action/include/rcl_action/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,6 @@ extern "C"

#include "rosidl_runtime_c/action_type_support_struct.h"

// rcl action specific ret codes in 2XXX
/// Action name does not pass validation return code.
#define RCL_RET_ACTION_NAME_INVALID 2000
/// Action goal accepted return code.
#define RCL_RET_ACTION_GOAL_ACCEPTED 2100
/// Action goal rejected return code.
#define RCL_RET_ACTION_GOAL_REJECTED 2101
/// Action client is invalid return code.
#define RCL_RET_ACTION_CLIENT_INVALID 2102
/// Action client failed to take response return code.
#define RCL_RET_ACTION_CLIENT_TAKE_FAILED 2103
/// Action server is invalid return code.
#define RCL_RET_ACTION_SERVER_INVALID 2200
/// Action server failed to take request return code.
#define RCL_RET_ACTION_SERVER_TAKE_FAILED 2201
/// Action goal handle invalid return code.
#define RCL_RET_ACTION_GOAL_HANDLE_INVALID 2300
/// Action invalid event return code.
#define RCL_RET_ACTION_GOAL_EVENT_INVALID 2301

// TODO(jacobperron): Move these to a common place for UUIDs
#define UUID_SIZE 16
#define uuidcmp(uuid0, uuid1) (0 == memcmp(uuid0, uuid1, UUID_SIZE))
Expand Down
6 changes: 3 additions & 3 deletions rcl_action/src/rcl_action/action_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ _recalculate_expire_timer(
rcl_time_point_value_t goal_terminal_timestamp;
ret = rcl_action_goal_handle_get_goal_terminal_timestamp(
goal_handle, &goal_terminal_timestamp);
if (RCL_ACTION_RET_NOT_TERMINATED_YET == ret) {
if (RCL_RET_ACTION_NOT_TERMINATED_YET == ret) {
continue;
}
if (RCL_RET_OK != ret) {
Expand Down Expand Up @@ -655,7 +655,7 @@ rcl_action_expire_goals(
}

ret = rcl_action_goal_handle_get_goal_terminal_timestamp(goal_handle, &goal_terminal_timestamp);
if (RCL_ACTION_RET_NOT_TERMINATED_YET == ret) {
if (RCL_RET_ACTION_NOT_TERMINATED_YET == ret) {
continue;
}
if (RCL_RET_OK != ret) {
Expand Down Expand Up @@ -738,7 +738,7 @@ rcl_action_notify_goal_done(
rcl_time_point_value_t goal_terminal_timestamp;
rcl_ret_t ret = rcl_action_goal_handle_get_goal_terminal_timestamp(
goal_handle, &goal_terminal_timestamp);
if (RCL_ACTION_RET_NOT_TERMINATED_YET == ret) {
if (RCL_RET_ACTION_NOT_TERMINATED_YET == ret) {
ret = rcl_action_goal_handle_set_goal_terminal_timestamp(goal_handle, current_time);
if (RCL_RET_OK != ret) {
return RCL_RET_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion rcl_action/src/rcl_action/goal_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ rcl_action_goal_handle_get_goal_terminal_timestamp(
RCL_CHECK_ARGUMENT_FOR_NULL(timestamp, RCL_RET_INVALID_ARGUMENT);

if (goal_handle->impl->goal_terminal_timestamp == INVAILD_GOAL_TERMINAL_TIMESTAMP) {
return RCL_ACTION_RET_NOT_TERMINATED_YET;
return RCL_RET_ACTION_NOT_TERMINATED_YET;
}

*timestamp = goal_handle->impl->goal_terminal_timestamp;
Expand Down
2 changes: 1 addition & 1 deletion rcl_action/test/rcl_action/test_goal_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ TEST(TestGoalHandle, rcl_action_goal_handle_get_goal_terminal_timestamp)

rcl_time_point_value_t timestamp;
ret = rcl_action_goal_handle_get_goal_terminal_timestamp(&goal_handle, &timestamp);
EXPECT_EQ(ret, RCL_ACTION_RET_NOT_TERMINATED_YET) << rcl_get_error_string().str;
EXPECT_EQ(ret, RCL_RET_ACTION_NOT_TERMINATED_YET) << rcl_get_error_string().str;
rcl_reset_error();

EXPECT_EQ(RCL_RET_OK, rcl_action_goal_handle_fini(&goal_handle));
Expand Down

0 comments on commit 1e565d5

Please sign in to comment.