-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# The CleanupController service allows you to cleanup a single controller | ||
# from controller_manager | ||
|
||
# To cleanup a controller, specify the "name" of the controller. | ||
# The return value "ok" indicates if the controller was successfully | ||
# cleaned up or not | ||
|
||
string name | ||
--- | ||
bool ok |
This file contains 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2020 PAL Robotics S.L. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from controller_manager import cleanup_controller | ||
|
||
from ros2cli.node.direct import add_arguments | ||
from ros2cli.node.strategy import NodeStrategy | ||
from ros2cli.verb import VerbExtension | ||
|
||
from ros2controlcli.api import add_controller_mgr_parsers, LoadedControllerNameCompleter | ||
|
||
|
||
class CleanupControllerVerb(VerbExtension): | ||
"""Cleanup a controller in a controller manager.""" | ||
|
||
def add_arguments(self, parser, cli_name): | ||
add_arguments(parser) | ||
arg = parser.add_argument("controller_name", help="Name of the controller") | ||
arg.completer = LoadedControllerNameCompleter() | ||
add_controller_mgr_parsers(parser) | ||
|
||
def main(self, *, args): | ||
with NodeStrategy(args) as node: | ||
response = cleanup_controller(node, args.controller_manager, args.controller_name) | ||
if not response.ok: | ||
return "Error cleanup controllers, check controller_manager logs" | ||
|
||
print(f"Successfully cleaned up controller {args.controller_name}") | ||
return 0 |
This file contains 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