-
Notifications
You must be signed in to change notification settings - Fork 294
initial command line interface #12
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *__pycache__* |
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -3,18 +3,23 @@ | |
| <package format="2"> | ||
| <name>ros2bag</name> | ||
| <version>0.0.0</version> | ||
| <description>ROSBag2 verb for ros2cli</description> | ||
| <maintainer email="[email protected]">Karsten Knese</maintainer> | ||
| <description> | ||
| Entry point for rosbag in ROS 2 | ||
| </description> | ||
| <maintainer email="[email protected]">Karsten Knese</maintainer> | ||
| <license>Apache License 2.0</license> | ||
|
|
||
| <buildtool_depend>ament_cmake</buildtool_depend> | ||
|
|
||
| <depend>rclpy</depend> | ||
| <depend>ros2cli</depend> | ||
|
|
||
| <test_depend>ament_lint_auto</test_depend> | ||
| <test_depend>ament_lint_common</test_depend> | ||
| <exec_depend>python3-yaml</exec_depend> | ||
|
|
||
| <test_depend>ament_copyright</test_depend> | ||
| <test_depend>ament_flake8</test_depend> | ||
| <test_depend>ament_pep257</test_depend> | ||
| <test_depend>python3-pytest</test_depend> | ||
|
|
||
| <export> | ||
| <build_type>ament_cmake</build_type> | ||
| <build_type>ament_python</build_type> | ||
| </export> | ||
| </package> | ||
Empty file.
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Copyright 2018 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. | ||
|
|
||
| import rclpy | ||
|
|
||
|
|
||
Empty file.
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Copyright 2018 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.command import add_subparsers | ||
| from ros2cli.command import CommandExtension | ||
| from ros2cli.verb import get_verb_extensions | ||
|
|
||
|
|
||
| class BagCommand(CommandExtension): | ||
| """Various rosbag related sub-commands.""" | ||
|
|
||
| def add_arguments(self, parser, cli_name): | ||
| self._subparser = parser | ||
|
|
||
| # get verb extensions and let them add their arguments | ||
| verb_extensions = get_verb_extensions('ros2bag.verb') | ||
| add_subparsers( | ||
| parser, cli_name, '_verb', verb_extensions, required=False) | ||
|
|
||
| def main(self, *, parser, args): | ||
| if not hasattr(args, '_verb'): | ||
| # in case no verb was passed | ||
| self._subparser.print_help() | ||
| return 0 | ||
|
|
||
| extension = getattr(args, '_verb') | ||
|
|
||
| # call the verb's main method | ||
| return extension.main(args=args) |
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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright 2018 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.plugin_system import PLUGIN_SYSTEM_VERSION | ||
| from ros2cli.plugin_system import satisfies_version | ||
|
|
||
|
|
||
| class VerbExtension: | ||
| """ | ||
| The extension point for 'bag' verb extensions. | ||
|
|
||
| The following properties must be defined: | ||
| * `NAME` (will be set to the entry point name) | ||
|
|
||
| The following methods must be defined: | ||
| * `main` | ||
|
|
||
| The following methods can be defined: | ||
| * `add_arguments` | ||
| """ | ||
|
|
||
| NAME = None | ||
| EXTENSION_POINT_VERSION = '0.1' | ||
|
|
||
| def __init__(self): | ||
| super(VerbExtension, self).__init__() | ||
| satisfies_version(PLUGIN_SYSTEM_VERSION, '^0.1') | ||
|
|
||
| def add_arguments(self, parser, cli_name): | ||
| pass | ||
|
|
||
| def main(self, *, args): | ||
| raise NotImplementedError() |
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Copyright 2018 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. | ||
|
|
||
| import sys | ||
|
|
||
| from ros2bag.verb import VerbExtension | ||
|
|
||
|
|
||
| class InfoVerb(VerbExtension): | ||
| """ros2 bag info.""" | ||
|
|
||
| def add_arguments(self, parser, cli_name): # noqa: D102 | ||
| arg = parser.add_argument( | ||
| 'bag_file', help='bag file to introspect') | ||
|
|
||
| def main(self, *, args): # noqa: D102 | ||
| bag_file = args.bag_file | ||
| print('calling ros2 bag info on', bag_file) |
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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Copyright 2018 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 ros2bag.verb import VerbExtension | ||
|
|
||
|
|
||
| class PlayVerb(VerbExtension): | ||
| """ros2 bag play.""" | ||
|
|
||
| def add_arguments(self, parser, cli_name): # noqa: D102 | ||
| parser.add_argument( | ||
| 'bag_file', help='bag file to replay') | ||
|
|
||
| def main(self, *, args): # noqa: D102 | ||
| bag_file = args.bag_file | ||
| print('calling ros2 bag play on', bag_file) |
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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Copyright 2018 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. | ||
|
|
||
| import sys | ||
| import time | ||
|
|
||
| from ros2cli.node.strategy import add_arguments | ||
| from ros2cli.node.strategy import NodeStrategy | ||
|
|
||
| from ros2bag.verb import VerbExtension | ||
|
|
||
|
|
||
| class RecordVerb(VerbExtension): | ||
| """ros2 bag record.""" | ||
|
|
||
| def add_arguments(self, parser, cli_name): # noqa: D102 | ||
| add_arguments(parser) | ||
| parser.add_argument( | ||
| '-a', '--all', action='store_true', help='recording all topics') | ||
| parser.add_argument( | ||
| 'topics', nargs='*', help='topics to be recorded') | ||
|
|
||
| def main(self, *, args): # noqa: D102 | ||
| if args.all and args.topics: | ||
| print('invalid choice: Can not specify topics and -a at the same time') | ||
| return | ||
|
|
||
| with NodeStrategy(args) as node: | ||
| if args.all: | ||
| t_and_n = node.get_topic_names_and_types() | ||
| print(t_and_n) | ||
| topics = [t for t,n in node.get_topic_names_and_types()] | ||
| if args.topics: | ||
| topics = args.topics | ||
| print('topics to be recorded:', topics) |
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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| from setuptools import find_packages | ||
| from setuptools import setup | ||
|
|
||
| setup( | ||
| name='ros2bag', | ||
| version='0.0.0', | ||
| packages=find_packages(exclude=['test']), | ||
| install_requires=['ros2cli'], | ||
| zip_safe=True, | ||
| author='Karsten Knese', | ||
| author_email='[email protected]', | ||
| maintainer='Karsten Knese', | ||
| maintainer_email='[email protected]', | ||
| keywords=[], | ||
| classifiers=[ | ||
| 'Environment :: Console', | ||
| 'Intended Audience :: Developers', | ||
| 'License :: OSI Approved :: Apache Software License', | ||
| 'Programming Language :: Python', | ||
| ], | ||
| description='Entry point for rosbag in ROS 2', | ||
| long_description="""\ | ||
| The package provides the rosbag command for the ROS 2 command line tools.""", | ||
| license='Apache License, Version 2.0', | ||
| tests_require=['pytest'], | ||
| entry_points={ | ||
| 'ros2cli.command': [ | ||
| 'bag = ros2bag.command.bag:BagCommand', | ||
| ], | ||
| 'ros2cli.extension_point': [ | ||
| 'ros2bag.verb = ros2bag.verb:VerbExtension', | ||
| ], | ||
| 'ros2bag.verb': [ | ||
| 'info = ros2bag.verb.info:InfoVerb', | ||
| 'play = ros2bag.verb.play:PlayVerb', | ||
| 'record = ros2bag.verb.record:RecordVerb', | ||
| ], | ||
| } | ||
| ) |
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.
Could this file just be empty and the dependency on rclpy removed from the package.xml ?