Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/rosdiscover/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _launch(config: Config) -> SystemSummary:
) as interpreter:
Copy link
Member

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_image with Interpreter.for_config. (Alternatively, we could be more OO-friendly by adding an interpreter() method to Config, that produces an interpreter for a given configuration.)

for fn_launch in config.launches:
logger.info(f"simulating launch [{fn_launch}]")
interpreter.launch(fn_launch)
interpreter.launch(fn_launch, config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make the changes above, we wouldn't need to pass config here.

return interpreter.summarise()


Expand Down
2 changes: 2 additions & 0 deletions src/rosdiscover/interpreter/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from loguru import logger
import attr
import dockerblade
from roswire import App
import roswire.name as rosname
import typing

Expand All @@ -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)
Expand Down
22 changes: 15 additions & 7 deletions src/rosdiscover/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .model import Model
from .summary import SystemSummary
from .parameter import ParameterServer
from ..config import Config


class Interpreter:
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could drop the config parameter if configuration becomes a property of Interpreter.

# FIXME this is waaay too permissive
except Exception:
logger.exception(f"failed to launch node: {node.name}")
Expand All @@ -90,6 +92,7 @@ def _load_nodelet(self,
namespace: str,
launch_filename: str,
remappings: Dict[str, str],
config: Config,
Copy link
Member

Choose a reason for hiding this comment

The 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.
Expand Down Expand Up @@ -132,7 +135,8 @@ def _load_nodelet(self,
namespace=namespace,
launch_filename=launch_filename,
remappings=remappings,
args='')
args='',
config=config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above


def _load(self,
pkg: str,
Expand All @@ -141,7 +145,8 @@ def _load(self,
namespace: str,
launch_filename: str,
remappings: Dict[str, str],
args: str
args: str,
config: Config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

) -> None:
"""Loads a node using the provided instructions.

Expand Down Expand Up @@ -182,7 +187,8 @@ def _load(self,
name=name,
namespace=namespace,
launch_filename=launch_filename,
remappings=remappings)
remappings=remappings,
config=config)
Copy link
Member

Choose a reason for hiding this comment

The 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('/')
Expand All @@ -192,7 +198,8 @@ def _load(self,
namespace=namespace,
launch_filename=launch_filename,
remappings=remappings,
manager=mgr)
manager=mgr,
config=config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above


if remappings:
logger.info(f"using remappings: {remappings}")
Expand All @@ -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)
Expand Down