Skip to content

Commit

Permalink
Fix a bad bug in fetching the lifecycle transitions. (#1321)
Browse files Browse the repository at this point in the history
We were fetching one more lifecycle transition than existed
in the source list (i.e. we should use < instead of <=).

In turn, this allows us to enable the test_lifecycle.py test,
and to fix the spurious "empty" string in the expected states.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette authored Jul 26, 2024
1 parent f7dd807 commit 2a8f23e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions rclpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ if(BUILD_TESTING)
test/test_expand_topic_name.py
test/test_guard_condition.py
test/test_init_shutdown.py
test/test_lifecycle.py
test/test_logging.py
test/test_logging_rosout.py
test/test_logging_service.py
Expand Down
2 changes: 1 addition & 1 deletion rclpy/src/rclpy/lifecycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class LifecycleStateMachine : public rclpy::Destroyable,
{
std::vector<std::tuple<uint8_t, std::string>> ret;
ret.reserve(state_machine_->transition_map.states_size);
for (size_t i = 0; i <= state_machine_->transition_map.states_size; ++i) {
for (size_t i = 0; i < state_machine_->transition_map.states_size; ++i) {
ret.emplace_back(
std::make_tuple(
state_machine_->transition_map.states[i].id,
Expand Down
2 changes: 1 addition & 1 deletion rclpy/test/test_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def cleanup():
states_labels = {state.label for state in resp.available_states}
assert states_labels == {
'unknown', 'unconfigured', 'inactive', 'active', 'finalized', 'configuring', 'cleaningup',
'shuttingdown', 'activating', 'deactivating', 'errorprocessing', ''
'shuttingdown', 'activating', 'deactivating', 'errorprocessing'
}
req = lifecycle_msgs.srv.GetAvailableTransitions.Request()
resp = get_available_transitions_cli.call(req)
Expand Down

0 comments on commit 2a8f23e

Please sign in to comment.