rcl_action - user friendly error messages for invalid transitions (#448)
* user friendly error messages for invalid transitions Signed-off-by: Siddharth Kucheria <kucheria@usc.edu>
This commit is contained in:
parent
0736f93cc0
commit
9566f39d60
3 changed files with 15 additions and 3 deletions
|
@ -93,6 +93,11 @@ typedef int8_t rcl_action_goal_state_t;
|
||||||
#define GOAL_STATE_ABORTED action_msgs__msg__GoalStatus__STATUS_ABORTED
|
#define GOAL_STATE_ABORTED action_msgs__msg__GoalStatus__STATUS_ABORTED
|
||||||
#define GOAL_STATE_NUM_STATES 7
|
#define GOAL_STATE_NUM_STATES 7
|
||||||
|
|
||||||
|
/// User friendly error messages for invalid trasntions
|
||||||
|
// Description variables in types.c should be changed if enum values change
|
||||||
|
extern const char * goal_state_descriptions[];
|
||||||
|
extern const char * goal_event_descriptions[];
|
||||||
|
|
||||||
/// Goal state transition events
|
/// Goal state transition events
|
||||||
typedef enum rcl_action_goal_event_t
|
typedef enum rcl_action_goal_event_t
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,9 +89,9 @@ rcl_action_update_goal_state(
|
||||||
goal_handle->impl->state, goal_event);
|
goal_handle->impl->state, goal_event);
|
||||||
if (GOAL_STATE_UNKNOWN == new_state) {
|
if (GOAL_STATE_UNKNOWN == new_state) {
|
||||||
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
|
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
|
||||||
"goal_handle attempted invalid transition from state %d with event %d",
|
"goal_handle attempted invalid transition from state %s with event %s",
|
||||||
goal_handle->impl->state,
|
goal_state_descriptions[goal_handle->impl->state],
|
||||||
goal_event);
|
goal_event_descriptions[goal_event]);
|
||||||
return RCL_RET_ACTION_GOAL_EVENT_INVALID;
|
return RCL_RET_ACTION_GOAL_EVENT_INVALID;
|
||||||
}
|
}
|
||||||
goal_handle->impl->state = new_state;
|
goal_handle->impl->state = new_state;
|
||||||
|
|
|
@ -132,6 +132,13 @@ rcl_action_cancel_response_fini(rcl_action_cancel_response_t * cancel_response)
|
||||||
return RCL_RET_OK;
|
return RCL_RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Values should be changed if enum values change
|
||||||
|
const char * goal_state_descriptions[] =
|
||||||
|
{"UNKNOWN", "ACCEPTED", "EXECUTING", "CANCELING", "SUCCEEDED", "CANCELED", "ABORTED"};
|
||||||
|
|
||||||
|
const char * goal_event_descriptions[] =
|
||||||
|
{"EXECUTE", "CANCEL_GOAL", "SUCCEED", "ABORT", "CANCELED", "NUM_EVENTS"};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue