-
Notifications
You must be signed in to change notification settings - Fork 1
translator from LaunchConfiguration to YML #86
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
Open
mvkashyap
wants to merge
14
commits into
master
Choose a base branch
from
Issue78
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b2965de
translator from LaunchConfiguration to YML
mvkashyap 66a06b6
Style errors
mvkashyap affad9c
Style 2
mvkashyap 4bcbbbe
Added json, cleaned up code
mvkashyap 3969e53
added comment detailing direct use of variables
mvkashyap 9803b19
style
mvkashyap 743d5f8
Added commandline arguments
mvkashyap 16824db
Fixed comment
mvkashyap 6d17464
Fixed comment
mvkashyap 9f5d2f2
Added a commandline argument for output file
mvkashyap 540e041
Style
mvkashyap c15b9d2
Update to IncludeLaunchDesciption to load launch file
mvkashyap 4c07aaf
Style
mvkashyap 38ee4b7
Style
mvkashyap 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,52 @@ | ||
| import json | ||
| import argparse | ||
| from launch.actions import IncludeLaunchDescription | ||
| from launch_ros.actions import Node | ||
| from launch.launch_description_sources import get_launch_description_from_python_launch_file | ||
|
|
||
|
|
||
| def toyaml(nodes): | ||
| to_yaml = {} | ||
| no_name = 0 | ||
| for node in nodes: | ||
| if isinstance(node, IncludeLaunchDescription): | ||
| description_from_node = node._IncludeLaunchDescription__launch_description_source.try_get_launch_description_without_context() | ||
| if description_from_node is None: | ||
| continue | ||
| nodes1 = description_from_node.entities | ||
| to_yaml.update(toyaml(nodes1)) | ||
| if isinstance(node, Node): | ||
| # Note: The code directly accesses variables since there are no getters for | ||
| # these specific variables in launch. | ||
| # This code might break with changed implementations of launch | ||
| dic = {} | ||
| if node._Node__node_name: | ||
| name_entry = node._Node__node_name | ||
| dic['name'] = node._Node__node_name | ||
| else: | ||
| name_entry = 'unknown' + str(no_name) | ||
| no_name += 1 | ||
| dic['name'] = name_entry | ||
| if node._Node__node_namespace: | ||
| dic['namespace'] = node._Node__node_namespace | ||
| if node._Node__node_executable: | ||
| dic['executable'] = node._Node__node_executable | ||
| if node._Node__package: | ||
| dic['package'] = node._Node__package | ||
| to_yaml[name_entry] = dic | ||
| return to_yaml | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| parser = argparse.ArgumentParser(description='Find nodes') | ||
| parser.add_argument('launchfile', type=str) | ||
| parser.add_argument('--output', type=str) | ||
ChrisTimperley marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| args = parser.parse_args() | ||
| if args.output: | ||
| yaml_file = args.output | ||
| else: | ||
| yaml_file = 'arch.yml' | ||
| description = get_launch_description_from_python_launch_file(args.launchfile) | ||
| nodes = description.entities | ||
| with open(yaml_file, 'w') as f: | ||
| f.write(json.dumps(toyaml(nodes), indent=4, separators=(". ", " = "))) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.