-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Added tool to request transition to ErrorState #1758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
|
|
||
| using std::string; | ||
| using lifecycle_msgs::msg::Transition; | ||
| using lifecycle_msgs::msg::State; | ||
|
|
||
| namespace nav2_util | ||
| { | ||
|
|
@@ -98,4 +99,65 @@ void reset_lifecycle_nodes( | |
| } | ||
| } | ||
|
|
||
| static void processErrorLifecycleNode( | ||
| const std::string & node_name, | ||
| const std::chrono::seconds service_call_timeout, | ||
| const int retries) | ||
| { | ||
| LifecycleServiceClient sc(node_name); | ||
| uint8_t transition; | ||
| // Each state of the lifecycle node has a specific transition | ||
| // to the ErrorProcessing state. Some states do not support transitions | ||
| // to ErrorProcessing. | ||
| switch (sc.get_state(service_call_timeout)) { | ||
| case State::PRIMARY_STATE_UNKNOWN: | ||
|
||
| return; | ||
| case State::PRIMARY_STATE_UNCONFIGURED: | ||
| return; | ||
| case State::PRIMARY_STATE_INACTIVE: | ||
| return; | ||
| case State::PRIMARY_STATE_ACTIVE: | ||
| return; | ||
| case State::PRIMARY_STATE_FINALIZED: | ||
| return; | ||
| case State::TRANSITION_STATE_CONFIGURING: | ||
| transition = Transition::TRANSITION_ON_CONFIGURE_ERROR; | ||
| break; | ||
| case State::TRANSITION_STATE_CLEANINGUP: | ||
| transition = Transition::TRANSITION_ON_CLEANUP_ERROR; | ||
| break; | ||
| case State::TRANSITION_STATE_SHUTTINGDOWN: | ||
| transition = Transition::TRANSITION_ON_SHUTDOWN_ERROR; | ||
| break; | ||
| case State::TRANSITION_STATE_ACTIVATING: | ||
| transition = Transition::TRANSITION_ON_ACTIVATE_ERROR; | ||
| break; | ||
| case State::TRANSITION_STATE_DEACTIVATING: | ||
| transition = Transition::TRANSITION_ON_DEACTIVATE_ERROR; | ||
| break; | ||
| case State::TRANSITION_STATE_ERRORPROCESSING: | ||
| transition = Transition::TRANSITION_ON_ERROR_ERROR; | ||
| break; | ||
| default: | ||
| return; | ||
| } | ||
|
|
||
| // Despite waiting for the service to be available and using reliable transport | ||
| // service calls still frequently hang. To get reliable reset it's necessary | ||
| // to timeout the service call and retry it when that happens. | ||
| RETRY( | ||
| sc.change_state(transition, service_call_timeout), | ||
| retries); | ||
| } | ||
|
|
||
| void process_error_lifecycle_nodes( | ||
| const std::vector<std::string> & node_names, | ||
| const std::chrono::seconds service_call_timeout, | ||
| const int retries) | ||
| { | ||
| for (const auto & node_name : node_names) { | ||
| processErrorLifecycleNode(node_name, service_call_timeout, retries); | ||
| } | ||
| } | ||
|
|
||
| } // namespace nav2_util | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really curious, is this timeout issue still an issue? That was circa Bouncy when that message was added to this tool, we've come a long way since then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually have no idea, I added it as well for consistency with the other tools. I can take a look at it and see if this was fixed somewhere. Or if you know how to test it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, lets just leave it. Its not hurting anyone. But I would be curious if in your unit tests you set the number of retries to 0 so that it fails and see if we ever catch it in your development / CI later. If it doesn't cause problems, we can remove it later.