diff --git a/requirements.dev.txt b/requirements.dev.txt index 3f28dd47..2e19cf75 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -7,4 +7,4 @@ tox==3.15.1 coveralls==2.0.0 twine==3.1.1 wheel==0.34.2 -git+git://github.com/ChrisTimperley/roswire.git@e69dc7949ca456829d0b5da1caa39d1be7085aa7 +git+git://github.com/ChrisTimperley/roswire.git@db2bcac0f903313dc22d7a5b919fe99c4a2c53f5 diff --git a/src/rosdiscover/cli.py b/src/rosdiscover/cli.py index 81b6cc9c..8c018f8f 100644 --- a/src/rosdiscover/cli.py +++ b/src/rosdiscover/cli.py @@ -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) return interpreter.summarise() diff --git a/src/rosdiscover/interpreter/context.py b/src/rosdiscover/interpreter/context.py index 6eca22ed..692b046f 100644 --- a/src/rosdiscover/interpreter/context.py +++ b/src/rosdiscover/interpreter/context.py @@ -4,6 +4,7 @@ from loguru import logger import attr import dockerblade +from roswire import App import roswire.name as rosname import typing @@ -24,6 +25,7 @@ class NodeContext: args: str remappings: Mapping[str, str] launch_filename: str + app: "App" = attr.ib(repr=False) _params: ParameterServer = attr.ib(repr=False) _files: dockerblade.files.FileSystem = attr.ib(repr=False) _nodelet: bool = attr.ib(default=False, repr=False) diff --git a/src/rosdiscover/interpreter/interpreter.py b/src/rosdiscover/interpreter/interpreter.py index 9bfa8050..5dc552e0 100644 --- a/src/rosdiscover/interpreter/interpreter.py +++ b/src/rosdiscover/interpreter/interpreter.py @@ -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) # 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, 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) 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 ) -> 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) 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) 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)