Rename action state transitions (#409)
* Rename action state transitions Now using active verbs. Resolves #399. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This commit is contained in:
parent
edaa18ae4b
commit
26744b0e5d
6 changed files with 66 additions and 66 deletions
|
@ -329,7 +329,7 @@ TEST_F(TestActionServer, test_action_clear_expired_goals)
|
|||
handles.push_back(*goal_handle);
|
||||
// Transition executing to aborted
|
||||
ASSERT_EQ(RCL_RET_OK, rcl_action_update_goal_state(goal_handle, GOAL_EVENT_EXECUTE));
|
||||
ASSERT_EQ(RCL_RET_OK, rcl_action_update_goal_state(goal_handle, GOAL_EVENT_SET_ABORTED));
|
||||
ASSERT_EQ(RCL_RET_OK, rcl_action_update_goal_state(goal_handle, GOAL_EVENT_ABORT));
|
||||
// Set time to something far in the future
|
||||
ASSERT_EQ(RCL_RET_OK, rcl_set_ros_time_override(&this->clock, RCUTILS_S_TO_NS(99999)));
|
||||
// Clear with valid arguments
|
||||
|
|
|
@ -161,7 +161,7 @@ using EventStateActiveCancelableTuple =
|
|||
std::tuple<rcl_action_goal_event_t, rcl_action_goal_state_t, bool, bool>;
|
||||
using StateTransitionSequence = std::vector<EventStateActiveCancelableTuple>;
|
||||
const std::vector<std::string> event_strs = {
|
||||
"EXECUTE", "CANCEL", "SET_SUCCEEDED", "SET_ABORTED", "SET_CANCELED"};
|
||||
"EXECUTE", "CANCEL_GOAL", "SUCCEED", "ABORT", "CANCELED"};
|
||||
|
||||
class TestGoalHandleStateTransitionSequence
|
||||
: public ::testing::TestWithParam<StateTransitionSequence>
|
||||
|
@ -242,39 +242,39 @@ TEST_P(TestGoalHandleStateTransitionSequence, test_goal_handle_state_transitions
|
|||
const StateTransitionSequence valid_state_transition_sequences[] = {
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_EXECUTING, true, true),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_SET_CANCELED, GOAL_STATE_CANCELED, false, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL_GOAL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCELED, GOAL_STATE_CANCELED, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_EXECUTING, true, true),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_SET_SUCCEEDED, GOAL_STATE_SUCCEEDED, false, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL_GOAL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_SUCCEED, GOAL_STATE_SUCCEEDED, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_EXECUTING, true, true),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_SET_ABORTED, GOAL_STATE_ABORTED, false, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL_GOAL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_ABORT, GOAL_STATE_ABORTED, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_EXECUTING, true, true),
|
||||
std::make_tuple(GOAL_EVENT_SET_SUCCEEDED, GOAL_STATE_SUCCEEDED, false, false),
|
||||
std::make_tuple(GOAL_EVENT_SUCCEED, GOAL_STATE_SUCCEEDED, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_EXECUTING, true, true),
|
||||
std::make_tuple(GOAL_EVENT_SET_ABORTED, GOAL_STATE_ABORTED, false, false),
|
||||
std::make_tuple(GOAL_EVENT_ABORT, GOAL_STATE_ABORTED, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_CANCEL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_SET_CANCELED, GOAL_STATE_CANCELED, false, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL_GOAL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCELED, GOAL_STATE_CANCELED, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_CANCEL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_SET_ABORTED, GOAL_STATE_ABORTED, false, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL_GOAL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_ABORT, GOAL_STATE_ABORTED, false, false),
|
||||
},
|
||||
// This is an odd case, but valid nonetheless
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_CANCEL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_SET_SUCCEEDED, GOAL_STATE_SUCCEEDED, false, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL_GOAL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_SUCCEED, GOAL_STATE_SUCCEEDED, false, false),
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -287,26 +287,26 @@ INSTANTIATE_TEST_CASE_P(
|
|||
const StateTransitionSequence invalid_state_transition_sequences[] = {
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_EXECUTING, true, true),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL_GOAL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_UNKNOWN, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_EXECUTING, true, true),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL, GOAL_STATE_UNKNOWN, false, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL_GOAL, GOAL_STATE_CANCELING, true, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCEL_GOAL, GOAL_STATE_UNKNOWN, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_EXECUTING, true, true),
|
||||
std::make_tuple(GOAL_EVENT_EXECUTE, GOAL_STATE_UNKNOWN, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_SET_CANCELED, GOAL_STATE_UNKNOWN, false, false),
|
||||
std::make_tuple(GOAL_EVENT_CANCELED, GOAL_STATE_UNKNOWN, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_SET_SUCCEEDED, GOAL_STATE_UNKNOWN, false, false),
|
||||
std::make_tuple(GOAL_EVENT_SUCCEED, GOAL_STATE_UNKNOWN, false, false),
|
||||
},
|
||||
{
|
||||
std::make_tuple(GOAL_EVENT_SET_ABORTED, GOAL_STATE_UNKNOWN, false, false),
|
||||
std::make_tuple(GOAL_EVENT_ABORT, GOAL_STATE_UNKNOWN, false, false),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -24,27 +24,27 @@ TEST(TestGoalStateMachine, test_valid_transitions)
|
|||
EXPECT_EQ(GOAL_STATE_EXECUTING, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_ACCEPTED,
|
||||
GOAL_EVENT_CANCEL);
|
||||
GOAL_EVENT_CANCEL_GOAL);
|
||||
EXPECT_EQ(GOAL_STATE_CANCELING, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_EXECUTING,
|
||||
GOAL_EVENT_CANCEL);
|
||||
GOAL_EVENT_CANCEL_GOAL);
|
||||
EXPECT_EQ(GOAL_STATE_CANCELING, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_EXECUTING,
|
||||
GOAL_EVENT_SET_SUCCEEDED);
|
||||
GOAL_EVENT_SUCCEED);
|
||||
EXPECT_EQ(GOAL_STATE_SUCCEEDED, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_EXECUTING,
|
||||
GOAL_EVENT_SET_ABORTED);
|
||||
GOAL_EVENT_ABORT);
|
||||
EXPECT_EQ(GOAL_STATE_ABORTED, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_CANCELING,
|
||||
GOAL_EVENT_SET_CANCELED);
|
||||
GOAL_EVENT_CANCELED);
|
||||
EXPECT_EQ(GOAL_STATE_CANCELED, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_CANCELING,
|
||||
GOAL_EVENT_SET_ABORTED);
|
||||
GOAL_EVENT_ABORT);
|
||||
EXPECT_EQ(GOAL_STATE_ABORTED, state);
|
||||
}
|
||||
|
||||
|
@ -53,15 +53,15 @@ TEST(TestGoalStateMachine, test_invalid_transitions)
|
|||
// Invalid from ACCEPTED
|
||||
rcl_action_goal_state_t state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_ACCEPTED,
|
||||
GOAL_EVENT_SET_SUCCEEDED);
|
||||
GOAL_EVENT_SUCCEED);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_ACCEPTED,
|
||||
GOAL_EVENT_SET_ABORTED);
|
||||
GOAL_EVENT_ABORT);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_ACCEPTED,
|
||||
GOAL_EVENT_SET_CANCELED);
|
||||
GOAL_EVENT_CANCELED);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
|
||||
// Invalid from EXECUTING
|
||||
|
@ -71,7 +71,7 @@ TEST(TestGoalStateMachine, test_invalid_transitions)
|
|||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_EXECUTING,
|
||||
GOAL_EVENT_SET_CANCELED);
|
||||
GOAL_EVENT_CANCELED);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
|
||||
// Invalid from CANCELING
|
||||
|
@ -81,7 +81,7 @@ TEST(TestGoalStateMachine, test_invalid_transitions)
|
|||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_CANCELING,
|
||||
GOAL_EVENT_CANCEL);
|
||||
GOAL_EVENT_CANCEL_GOAL);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
|
||||
// Invalid from SUCCEEDED
|
||||
|
@ -91,19 +91,19 @@ TEST(TestGoalStateMachine, test_invalid_transitions)
|
|||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_SUCCEEDED,
|
||||
GOAL_EVENT_CANCEL);
|
||||
GOAL_EVENT_CANCEL_GOAL);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_SUCCEEDED,
|
||||
GOAL_EVENT_SET_SUCCEEDED);
|
||||
GOAL_EVENT_SUCCEED);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_SUCCEEDED,
|
||||
GOAL_EVENT_SET_ABORTED);
|
||||
GOAL_EVENT_ABORT);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_SUCCEEDED,
|
||||
GOAL_EVENT_SET_CANCELED);
|
||||
GOAL_EVENT_CANCELED);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
|
||||
// Invalid from ABORTED
|
||||
|
@ -113,19 +113,19 @@ TEST(TestGoalStateMachine, test_invalid_transitions)
|
|||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_ABORTED,
|
||||
GOAL_EVENT_CANCEL);
|
||||
GOAL_EVENT_CANCEL_GOAL);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_ABORTED,
|
||||
GOAL_EVENT_SET_SUCCEEDED);
|
||||
GOAL_EVENT_SUCCEED);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_ABORTED,
|
||||
GOAL_EVENT_SET_ABORTED);
|
||||
GOAL_EVENT_ABORT);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_ABORTED,
|
||||
GOAL_EVENT_SET_CANCELED);
|
||||
GOAL_EVENT_CANCELED);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
|
||||
// Invalid from CANCELED
|
||||
|
@ -135,18 +135,18 @@ TEST(TestGoalStateMachine, test_invalid_transitions)
|
|||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_CANCELED,
|
||||
GOAL_EVENT_CANCEL);
|
||||
GOAL_EVENT_CANCEL_GOAL);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_CANCELED,
|
||||
GOAL_EVENT_SET_SUCCEEDED);
|
||||
GOAL_EVENT_SUCCEED);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_CANCELED,
|
||||
GOAL_EVENT_SET_ABORTED);
|
||||
GOAL_EVENT_ABORT);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
state = rcl_action_transition_goal_state(
|
||||
GOAL_STATE_CANCELED,
|
||||
GOAL_EVENT_SET_CANCELED);
|
||||
GOAL_EVENT_CANCELED);
|
||||
EXPECT_EQ(GOAL_STATE_UNKNOWN, state);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue