-
Notifications
You must be signed in to change notification settings - Fork 1
Updated to allow config and app (and eventually the ros version) #107
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ def _launch(config: Config) -> SystemSummary: | |
| ) as interpreter: | ||
| for fn_launch in config.launches: | ||
| logger.info(f"simulating launch [{fn_launch}]") | ||
| interpreter.launch(fn_launch) | ||
| interpreter.launch(fn_launch, config) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we make the changes above, we wouldn't need to pass |
||
| return interpreter.summarise() | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| from .model import Model | ||
| from .summary import SystemSummary | ||
| from .parameter import ParameterServer | ||
| from ..config import Config | ||
|
|
||
|
|
||
| class Interpreter: | ||
|
|
@@ -43,7 +44,7 @@ def summarise(self) -> SystemSummary: | |
| node_to_summary = {s.fullname: s for s in node_summaries} | ||
| return SystemSummary(node_to_summary) | ||
|
|
||
| def launch(self, filename: str) -> None: | ||
| def launch(self, filename: str, configuration: Config) -> None: | ||
| """Simulates the effects of `roslaunch` using a given launch file.""" | ||
| # NOTE this method also supports command-line arguments | ||
| reader = LaunchFileReader(shell=self._app.shell, | ||
|
|
@@ -68,7 +69,8 @@ def launch(self, filename: str) -> None: | |
| namespace=node.namespace, # FIXME | ||
| launch_filename=node.filename, | ||
| remappings=remappings, | ||
| args=args) | ||
| args=args, | ||
| config=configuration) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could drop the |
||
| # FIXME this is waaay too permissive | ||
| except Exception: | ||
| logger.exception(f"failed to launch node: {node.name}") | ||
|
|
@@ -90,6 +92,7 @@ def _load_nodelet(self, | |
| namespace: str, | ||
| launch_filename: str, | ||
| remappings: Dict[str, str], | ||
| config: Config, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
| manager: Optional[str] = None | ||
| ) -> None: | ||
| """Loads a nodelet using the provided instructions. | ||
|
|
@@ -132,7 +135,8 @@ def _load_nodelet(self, | |
| namespace=namespace, | ||
| launch_filename=launch_filename, | ||
| remappings=remappings, | ||
| args='') | ||
| args='', | ||
| config=config) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
|
|
||
| def _load(self, | ||
| pkg: str, | ||
|
|
@@ -141,7 +145,8 @@ def _load(self, | |
| namespace: str, | ||
| launch_filename: str, | ||
| remappings: Dict[str, str], | ||
| args: str | ||
| args: str, | ||
| config: Config | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
| ) -> None: | ||
| """Loads a node using the provided instructions. | ||
|
|
||
|
|
@@ -182,7 +187,8 @@ def _load(self, | |
| name=name, | ||
| namespace=namespace, | ||
| launch_filename=launch_filename, | ||
| remappings=remappings) | ||
| remappings=remappings, | ||
| config=config) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
| else: | ||
| load, pkg_and_nodetype, mgr = args.split(' ') | ||
| pkg, _, nodetype = pkg_and_nodetype.partition('/') | ||
|
|
@@ -192,7 +198,8 @@ def _load(self, | |
| namespace=namespace, | ||
| launch_filename=launch_filename, | ||
| remappings=remappings, | ||
| manager=mgr) | ||
| manager=mgr, | ||
| config=config) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
|
|
||
| if remappings: | ||
| logger.info(f"using remappings: {remappings}") | ||
|
|
@@ -213,7 +220,8 @@ def _load(self, | |
| launch_filename=launch_filename, | ||
| remappings=remappings, | ||
| files=self._app.files, | ||
| params=self.params) | ||
| params=self.params, | ||
| app=config.app) | ||
| self.nodes[ctx.fullname] = ctx | ||
|
|
||
| model.eval(ctx) | ||
|
|
||
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.
We could improve this by replacing
Interpreter.for_imagewithInterpreter.for_config. (Alternatively, we could be more OO-friendly by adding aninterpreter()method toConfig, that produces an interpreter for a given configuration.)