[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:
parent
9351fd89c7
commit
8b00791a56
3 changed files with 88 additions and 45 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue