forked from ros2/ros2cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add rosparam verb load Signed-off-by: Victor Lopez <[email protected]> * Move load_parameter_file implementation to api, add test_verb_load Signed-off-by: Victor Lopez <[email protected]> * Apply fixes for linter Signed-off-by: Victor Lopez <[email protected]> * Remove TODO comment Signed-off-by: Victor Lopez <[email protected]> * Fix linter errors Signed-off-by: Audrow Nash <[email protected]> Co-authored-by: Audrow Nash <[email protected]>
- Loading branch information
1 parent
a4c12ef
commit b080691
Showing
5 changed files
with
397 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2021 Open Source Robotics Foundation, Inc. | ||
# | ||
# 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 ros2cli.node.direct import DirectNode | ||
from ros2cli.node.strategy import add_arguments | ||
from ros2cli.node.strategy import NodeStrategy | ||
from ros2node.api import get_absolute_node_name | ||
from ros2node.api import get_node_names | ||
from ros2node.api import NodeNameCompleter | ||
from ros2param.api import load_parameter_file | ||
from ros2param.verb import VerbExtension | ||
|
||
|
||
class LoadVerb(VerbExtension): | ||
"""Load parameter file for a node.""" | ||
|
||
def add_arguments(self, parser, cli_name): # noqa: D102 | ||
add_arguments(parser) | ||
arg = parser.add_argument( | ||
'node_name', help='Name of the ROS node') | ||
arg.completer = NodeNameCompleter( | ||
include_hidden_nodes_key='include_hidden_nodes') | ||
parser.add_argument( | ||
'--include-hidden-nodes', action='store_true', | ||
help='Consider hidden nodes as well') | ||
arg = parser.add_argument( | ||
'parameter_file', help='Parameter file') | ||
|
||
def main(self, *, args): # noqa: D102 | ||
with NodeStrategy(args) as node: | ||
node_names = get_node_names( | ||
node=node, include_hidden_nodes=args.include_hidden_nodes) | ||
|
||
node_name = get_absolute_node_name(args.node_name) | ||
if node_name not in {n.full_name for n in node_names}: | ||
return 'Node not found' | ||
|
||
with DirectNode(args) as node: | ||
load_parameter_file(node=node, node_name=node_name, parameter_file=args.parameter_file) |
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
Oops, something went wrong.