[rcl_action] Add function to check if goal can be transitioned to CANCELING (#325)

* [rcl_action] Add function for checking if goal can be transitioned to CANCELING

Add unit tests for the new function rcl_action_goal_handle_is_cancelable(), as well as rcl_action_goal_handle_is_active().
This commit is contained in:
Jacob Perron 2018-11-13 11:55:28 -08:00 committed by GitHub
parent 9351fd89c7
commit 8b00791a56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 88 additions and 45 deletions

View file

@ -137,6 +137,18 @@ rcl_action_goal_handle_is_active(const rcl_action_goal_handle_t * goal_handle)
}
}
bool
rcl_action_goal_handle_is_cancelable(const rcl_action_goal_handle_t * goal_handle)
{
if (!rcl_action_goal_handle_is_valid(goal_handle)) {
return false; // error message is set
}
// Check if the state machine reports a cancel event is valid
rcl_action_goal_state_t state = rcl_action_transition_goal_state(
goal_handle->impl->state, GOAL_EVENT_CANCEL);
return GOAL_STATE_CANCELING == state;
}
bool
rcl_action_goal_handle_is_valid(const rcl_action_goal_handle_t * goal_handle)
{