sierra-research 1.3.11__py3-none-any.whl → 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sierra/__init__.py +3 -3
- sierra/core/__init__.py +3 -3
- sierra/core/batchroot.py +223 -0
- sierra/core/cmdline.py +681 -1057
- sierra/core/compare.py +11 -0
- sierra/core/config.py +96 -88
- sierra/core/engine.py +306 -0
- sierra/core/execenv.py +380 -0
- sierra/core/expdef.py +11 -0
- sierra/core/experiment/__init__.py +1 -0
- sierra/core/experiment/bindings.py +150 -101
- sierra/core/experiment/definition.py +414 -245
- sierra/core/experiment/spec.py +83 -85
- sierra/core/exproot.py +44 -0
- sierra/core/generators/__init__.py +10 -0
- sierra/core/generators/experiment.py +528 -0
- sierra/core/generators/generator_factory.py +138 -137
- sierra/core/graphs/__init__.py +23 -0
- sierra/core/graphs/bcbridge.py +94 -0
- sierra/core/graphs/heatmap.py +245 -324
- sierra/core/graphs/pathset.py +27 -0
- sierra/core/graphs/schema.py +77 -0
- sierra/core/graphs/stacked_line.py +341 -0
- sierra/core/graphs/summary_line.py +506 -0
- sierra/core/logging.py +3 -2
- sierra/core/models/__init__.py +3 -1
- sierra/core/models/info.py +19 -0
- sierra/core/models/interface.py +52 -122
- sierra/core/pipeline/__init__.py +2 -5
- sierra/core/pipeline/pipeline.py +228 -126
- sierra/core/pipeline/stage1/__init__.py +10 -0
- sierra/core/pipeline/stage1/pipeline_stage1.py +45 -31
- sierra/core/pipeline/stage2/__init__.py +10 -0
- sierra/core/pipeline/stage2/pipeline_stage2.py +8 -11
- sierra/core/pipeline/stage2/runner.py +401 -0
- sierra/core/pipeline/stage3/__init__.py +12 -0
- sierra/core/pipeline/stage3/gather.py +321 -0
- sierra/core/pipeline/stage3/pipeline_stage3.py +37 -84
- sierra/core/pipeline/stage4/__init__.py +12 -2
- sierra/core/pipeline/stage4/pipeline_stage4.py +36 -354
- sierra/core/pipeline/stage5/__init__.py +12 -0
- sierra/core/pipeline/stage5/pipeline_stage5.py +33 -208
- sierra/core/pipeline/yaml.py +48 -0
- sierra/core/plugin.py +529 -62
- sierra/core/proc.py +11 -0
- sierra/core/prod.py +11 -0
- sierra/core/ros1/__init__.py +5 -1
- sierra/core/ros1/callbacks.py +22 -21
- sierra/core/ros1/cmdline.py +59 -88
- sierra/core/ros1/generators.py +159 -175
- sierra/core/ros1/variables/__init__.py +3 -0
- sierra/core/ros1/variables/exp_setup.py +122 -116
- sierra/core/startup.py +106 -76
- sierra/core/stat_kernels.py +4 -5
- sierra/core/storage.py +13 -32
- sierra/core/trampoline.py +30 -0
- sierra/core/types.py +116 -71
- sierra/core/utils.py +103 -106
- sierra/core/variables/__init__.py +1 -1
- sierra/core/variables/base_variable.py +12 -17
- sierra/core/variables/batch_criteria.py +387 -481
- sierra/core/variables/builtin.py +135 -0
- sierra/core/variables/exp_setup.py +19 -39
- sierra/core/variables/population_size.py +72 -76
- sierra/core/variables/variable_density.py +44 -68
- sierra/core/vector.py +1 -1
- sierra/main.py +256 -88
- sierra/plugins/__init__.py +119 -0
- sierra/plugins/compare/__init__.py +14 -0
- sierra/plugins/compare/graphs/__init__.py +19 -0
- sierra/plugins/compare/graphs/cmdline.py +120 -0
- sierra/plugins/compare/graphs/comparator.py +291 -0
- sierra/plugins/compare/graphs/inter_controller.py +531 -0
- sierra/plugins/compare/graphs/inter_scenario.py +297 -0
- sierra/plugins/compare/graphs/namecalc.py +53 -0
- sierra/plugins/compare/graphs/outputroot.py +73 -0
- sierra/plugins/compare/graphs/plugin.py +147 -0
- sierra/plugins/compare/graphs/preprocess.py +172 -0
- sierra/plugins/compare/graphs/schema.py +37 -0
- sierra/plugins/engine/__init__.py +14 -0
- sierra/plugins/engine/argos/__init__.py +18 -0
- sierra/plugins/{platform → engine}/argos/cmdline.py +144 -151
- sierra/plugins/{platform/argos/variables → engine/argos/generators}/__init__.py +5 -0
- sierra/plugins/engine/argos/generators/engine.py +394 -0
- sierra/plugins/engine/argos/plugin.py +393 -0
- sierra/plugins/{platform/argos/generators → engine/argos/variables}/__init__.py +5 -0
- sierra/plugins/engine/argos/variables/arena_shape.py +183 -0
- sierra/plugins/engine/argos/variables/cameras.py +240 -0
- sierra/plugins/engine/argos/variables/constant_density.py +112 -0
- sierra/plugins/engine/argos/variables/exp_setup.py +82 -0
- sierra/plugins/{platform → engine}/argos/variables/physics_engines.py +83 -87
- sierra/plugins/engine/argos/variables/population_constant_density.py +178 -0
- sierra/plugins/engine/argos/variables/population_size.py +115 -0
- sierra/plugins/engine/argos/variables/population_variable_density.py +123 -0
- sierra/plugins/engine/argos/variables/rendering.py +108 -0
- sierra/plugins/engine/ros1gazebo/__init__.py +18 -0
- sierra/plugins/engine/ros1gazebo/cmdline.py +175 -0
- sierra/plugins/{platform/ros1robot → engine/ros1gazebo}/generators/__init__.py +5 -0
- sierra/plugins/engine/ros1gazebo/generators/engine.py +125 -0
- sierra/plugins/engine/ros1gazebo/plugin.py +404 -0
- sierra/plugins/engine/ros1gazebo/variables/__init__.py +15 -0
- sierra/plugins/engine/ros1gazebo/variables/population_size.py +214 -0
- sierra/plugins/engine/ros1robot/__init__.py +18 -0
- sierra/plugins/engine/ros1robot/cmdline.py +159 -0
- sierra/plugins/{platform/ros1gazebo → engine/ros1robot}/generators/__init__.py +4 -0
- sierra/plugins/engine/ros1robot/generators/engine.py +95 -0
- sierra/plugins/engine/ros1robot/plugin.py +410 -0
- sierra/plugins/{hpc/local → engine/ros1robot/variables}/__init__.py +5 -0
- sierra/plugins/engine/ros1robot/variables/population_size.py +146 -0
- sierra/plugins/execenv/__init__.py +11 -0
- sierra/plugins/execenv/hpc/__init__.py +18 -0
- sierra/plugins/execenv/hpc/adhoc/__init__.py +18 -0
- sierra/plugins/execenv/hpc/adhoc/cmdline.py +30 -0
- sierra/plugins/execenv/hpc/adhoc/plugin.py +131 -0
- sierra/plugins/execenv/hpc/cmdline.py +137 -0
- sierra/plugins/execenv/hpc/local/__init__.py +18 -0
- sierra/plugins/execenv/hpc/local/cmdline.py +31 -0
- sierra/plugins/execenv/hpc/local/plugin.py +145 -0
- sierra/plugins/execenv/hpc/pbs/__init__.py +18 -0
- sierra/plugins/execenv/hpc/pbs/cmdline.py +30 -0
- sierra/plugins/execenv/hpc/pbs/plugin.py +121 -0
- sierra/plugins/execenv/hpc/slurm/__init__.py +18 -0
- sierra/plugins/execenv/hpc/slurm/cmdline.py +30 -0
- sierra/plugins/execenv/hpc/slurm/plugin.py +133 -0
- sierra/plugins/execenv/prefectserver/__init__.py +18 -0
- sierra/plugins/execenv/prefectserver/cmdline.py +66 -0
- sierra/plugins/execenv/prefectserver/dockerremote/__init__.py +18 -0
- sierra/plugins/execenv/prefectserver/dockerremote/cmdline.py +66 -0
- sierra/plugins/execenv/prefectserver/dockerremote/plugin.py +132 -0
- sierra/plugins/execenv/prefectserver/flow.py +66 -0
- sierra/plugins/execenv/prefectserver/local/__init__.py +18 -0
- sierra/plugins/execenv/prefectserver/local/cmdline.py +29 -0
- sierra/plugins/execenv/prefectserver/local/plugin.py +133 -0
- sierra/plugins/{hpc/adhoc → execenv/robot}/__init__.py +1 -0
- sierra/plugins/execenv/robot/turtlebot3/__init__.py +18 -0
- sierra/plugins/execenv/robot/turtlebot3/plugin.py +204 -0
- sierra/plugins/expdef/__init__.py +14 -0
- sierra/plugins/expdef/json/__init__.py +14 -0
- sierra/plugins/expdef/json/plugin.py +504 -0
- sierra/plugins/expdef/xml/__init__.py +14 -0
- sierra/plugins/expdef/xml/plugin.py +386 -0
- sierra/{core/hpc → plugins/proc}/__init__.py +1 -1
- sierra/plugins/proc/collate/__init__.py +15 -0
- sierra/plugins/proc/collate/cmdline.py +47 -0
- sierra/plugins/proc/collate/plugin.py +271 -0
- sierra/plugins/proc/compress/__init__.py +18 -0
- sierra/plugins/proc/compress/cmdline.py +47 -0
- sierra/plugins/proc/compress/plugin.py +123 -0
- sierra/plugins/proc/decompress/__init__.py +18 -0
- sierra/plugins/proc/decompress/plugin.py +96 -0
- sierra/plugins/proc/imagize/__init__.py +15 -0
- sierra/plugins/proc/imagize/cmdline.py +49 -0
- sierra/plugins/proc/imagize/plugin.py +270 -0
- sierra/plugins/proc/modelrunner/__init__.py +16 -0
- sierra/plugins/proc/modelrunner/plugin.py +250 -0
- sierra/plugins/proc/statistics/__init__.py +15 -0
- sierra/plugins/proc/statistics/cmdline.py +64 -0
- sierra/plugins/proc/statistics/plugin.py +390 -0
- sierra/plugins/{hpc → prod}/__init__.py +1 -0
- sierra/plugins/prod/graphs/__init__.py +18 -0
- sierra/plugins/prod/graphs/cmdline.py +269 -0
- sierra/plugins/prod/graphs/collate.py +279 -0
- sierra/plugins/prod/graphs/inter/__init__.py +13 -0
- sierra/plugins/prod/graphs/inter/generate.py +83 -0
- sierra/plugins/prod/graphs/inter/heatmap.py +86 -0
- sierra/plugins/prod/graphs/inter/line.py +134 -0
- sierra/plugins/prod/graphs/intra/__init__.py +15 -0
- sierra/plugins/prod/graphs/intra/generate.py +202 -0
- sierra/plugins/prod/graphs/intra/heatmap.py +74 -0
- sierra/plugins/prod/graphs/intra/line.py +114 -0
- sierra/plugins/prod/graphs/plugin.py +103 -0
- sierra/plugins/prod/graphs/targets.py +63 -0
- sierra/plugins/prod/render/__init__.py +18 -0
- sierra/plugins/prod/render/cmdline.py +72 -0
- sierra/plugins/prod/render/plugin.py +282 -0
- sierra/plugins/storage/__init__.py +5 -0
- sierra/plugins/storage/arrow/__init__.py +18 -0
- sierra/plugins/storage/arrow/plugin.py +38 -0
- sierra/plugins/storage/csv/__init__.py +9 -0
- sierra/plugins/storage/csv/plugin.py +12 -5
- sierra/version.py +3 -2
- sierra_research-1.5.0.dist-info/METADATA +238 -0
- sierra_research-1.5.0.dist-info/RECORD +186 -0
- {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info}/WHEEL +1 -2
- sierra/core/experiment/xml.py +0 -454
- sierra/core/generators/controller_generator_parser.py +0 -34
- sierra/core/generators/exp_creator.py +0 -351
- sierra/core/generators/exp_generators.py +0 -142
- sierra/core/graphs/scatterplot2D.py +0 -109
- sierra/core/graphs/stacked_line_graph.py +0 -251
- sierra/core/graphs/stacked_surface_graph.py +0 -220
- sierra/core/graphs/summary_line_graph.py +0 -371
- sierra/core/hpc/cmdline.py +0 -142
- sierra/core/models/graphs.py +0 -87
- sierra/core/pipeline/stage2/exp_runner.py +0 -286
- sierra/core/pipeline/stage3/imagizer.py +0 -149
- sierra/core/pipeline/stage3/run_collator.py +0 -317
- sierra/core/pipeline/stage3/statistics_calculator.py +0 -478
- sierra/core/pipeline/stage4/graph_collator.py +0 -320
- sierra/core/pipeline/stage4/inter_exp_graph_generator.py +0 -240
- sierra/core/pipeline/stage4/intra_exp_graph_generator.py +0 -317
- sierra/core/pipeline/stage4/model_runner.py +0 -168
- sierra/core/pipeline/stage4/rendering.py +0 -283
- sierra/core/pipeline/stage4/yaml_config_loader.py +0 -103
- sierra/core/pipeline/stage5/inter_scenario_comparator.py +0 -328
- sierra/core/pipeline/stage5/intra_scenario_comparator.py +0 -989
- sierra/core/platform.py +0 -493
- sierra/core/plugin_manager.py +0 -369
- sierra/core/root_dirpath_generator.py +0 -241
- sierra/plugins/hpc/adhoc/plugin.py +0 -125
- sierra/plugins/hpc/local/plugin.py +0 -81
- sierra/plugins/hpc/pbs/__init__.py +0 -9
- sierra/plugins/hpc/pbs/plugin.py +0 -126
- sierra/plugins/hpc/slurm/__init__.py +0 -9
- sierra/plugins/hpc/slurm/plugin.py +0 -130
- sierra/plugins/platform/__init__.py +0 -9
- sierra/plugins/platform/argos/__init__.py +0 -9
- sierra/plugins/platform/argos/generators/platform_generators.py +0 -383
- sierra/plugins/platform/argos/plugin.py +0 -337
- sierra/plugins/platform/argos/variables/arena_shape.py +0 -145
- sierra/plugins/platform/argos/variables/cameras.py +0 -243
- sierra/plugins/platform/argos/variables/constant_density.py +0 -136
- sierra/plugins/platform/argos/variables/exp_setup.py +0 -113
- sierra/plugins/platform/argos/variables/population_constant_density.py +0 -175
- sierra/plugins/platform/argos/variables/population_size.py +0 -102
- sierra/plugins/platform/argos/variables/population_variable_density.py +0 -132
- sierra/plugins/platform/argos/variables/rendering.py +0 -104
- sierra/plugins/platform/ros1gazebo/__init__.py +0 -9
- sierra/plugins/platform/ros1gazebo/cmdline.py +0 -213
- sierra/plugins/platform/ros1gazebo/generators/platform_generators.py +0 -137
- sierra/plugins/platform/ros1gazebo/plugin.py +0 -335
- sierra/plugins/platform/ros1gazebo/variables/__init__.py +0 -10
- sierra/plugins/platform/ros1gazebo/variables/population_size.py +0 -204
- sierra/plugins/platform/ros1robot/__init__.py +0 -9
- sierra/plugins/platform/ros1robot/cmdline.py +0 -175
- sierra/plugins/platform/ros1robot/generators/platform_generators.py +0 -112
- sierra/plugins/platform/ros1robot/plugin.py +0 -373
- sierra/plugins/platform/ros1robot/variables/__init__.py +0 -10
- sierra/plugins/platform/ros1robot/variables/population_size.py +0 -146
- sierra/plugins/robot/__init__.py +0 -9
- sierra/plugins/robot/turtlebot3/__init__.py +0 -9
- sierra/plugins/robot/turtlebot3/plugin.py +0 -194
- sierra_research-1.3.11.data/data/share/man/man1/sierra-cli.1 +0 -2349
- sierra_research-1.3.11.data/data/share/man/man7/sierra-examples.7 +0 -508
- sierra_research-1.3.11.data/data/share/man/man7/sierra-exec-envs.7 +0 -331
- sierra_research-1.3.11.data/data/share/man/man7/sierra-glossary.7 +0 -285
- sierra_research-1.3.11.data/data/share/man/man7/sierra-platforms.7 +0 -358
- sierra_research-1.3.11.data/data/share/man/man7/sierra-usage.7 +0 -729
- sierra_research-1.3.11.data/data/share/man/man7/sierra.7 +0 -78
- sierra_research-1.3.11.dist-info/METADATA +0 -492
- sierra_research-1.3.11.dist-info/RECORD +0 -133
- sierra_research-1.3.11.dist-info/top_level.txt +0 -1
- {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info}/entry_points.txt +0 -0
- {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info/licenses}/LICENSE +0 -0
sierra/core/ros1/callbacks.py
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
#
|
5
|
-
"""Common classes and callbacks :term:`
|
6
|
-
|
7
|
-
"""
|
5
|
+
"""Common classes and callbacks :term:`Engines <Engine>` using :term:`ROS1`."""
|
8
6
|
|
9
7
|
# Core packages
|
10
8
|
import typing as tp
|
@@ -13,33 +11,36 @@ import typing as tp
|
|
13
11
|
|
14
12
|
# Project packages
|
15
13
|
from sierra.core import types
|
16
|
-
from sierra.core.experiment import
|
14
|
+
from sierra.core.experiment import definition
|
17
15
|
|
18
16
|
|
19
|
-
def population_size_from_pickle(
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
def population_size_from_pickle(
|
18
|
+
adds_def: tp.Union[definition.AttrChangeSet, definition.ElementAddList],
|
19
|
+
main_config: types.YAMLDict,
|
20
|
+
cmdopts: types.Cmdopts,
|
21
|
+
) -> int:
|
22
|
+
"""Extract population size from unpickled experiment definition."""
|
23
23
|
for add in adds_def:
|
24
|
-
if
|
25
|
-
return int(add.attr[
|
24
|
+
if "name" in add.attr and "n_agents" in add.attr["name"]:
|
25
|
+
return int(add.attr["value"])
|
26
26
|
|
27
27
|
return 0
|
28
28
|
|
29
29
|
|
30
|
-
def population_size_from_def(
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def population_size_from_def(
|
31
|
+
exp_def: definition.BaseExpDef, main_config: types.YAMLDict, cmdopts: types.Cmdopts
|
32
|
+
) -> int:
|
33
|
+
"""Extract population size from experiment definition."""
|
34
|
+
return population_size_from_pickle(exp_def.element_adds, main_config, cmdopts)
|
34
35
|
|
35
36
|
|
36
|
-
def robot_prefix_extract(main_config: types.YAMLDict,
|
37
|
-
|
38
|
-
return main_config[
|
37
|
+
def robot_prefix_extract(main_config: types.YAMLDict, cmdopts: types.Cmdopts) -> str:
|
38
|
+
"""Extract the common robot prefix based on cmdline opts + YAML config."""
|
39
|
+
return str(main_config["ros"]["robots"][cmdopts["robot"]]["prefix"])
|
39
40
|
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
__all__ = [
|
43
|
+
"population_size_from_pickle",
|
44
|
+
"population_size_from_def",
|
45
|
+
"robot_prefix_extract",
|
45
46
|
]
|
sierra/core/ros1/cmdline.py
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
#
|
5
|
-
"""Common cmdline classes :term:`
|
6
|
-
|
7
|
-
"""
|
5
|
+
"""Common cmdline classes :term:`Engines <Engine>` using :term:`ROS1`."""
|
8
6
|
|
9
7
|
# Core packages
|
10
8
|
import typing as tp
|
@@ -14,37 +12,23 @@ import argparse
|
|
14
12
|
|
15
13
|
# Project packages
|
16
14
|
from sierra.core import types, config
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
class ROSCmdline(cmd.BaseCmdline):
|
21
|
-
"""Defines :term:`ROS1` common command line arguments.
|
22
|
-
|
23
|
-
"""
|
24
|
-
|
25
|
-
def __init__(self,
|
26
|
-
stages: tp.List[int]) -> None:
|
27
|
-
self.parser = argparse.ArgumentParser(add_help=False,
|
28
|
-
allow_abbrev=False)
|
29
|
-
self.scaffold_cli()
|
30
|
-
self.init_cli(stages)
|
15
|
+
from sierra.plugins import PluginCmdline
|
31
16
|
|
32
|
-
def scaffold_cli(self) -> None:
|
33
|
-
self.multistage = self.parser.add_argument_group('Multi-stage options',
|
34
|
-
'Options which are used in multiple pipeline stages')
|
35
|
-
self.stage1_exp = self.parser.add_argument_group(
|
36
|
-
'Stage1: Experiment generation')
|
37
17
|
|
38
|
-
|
39
|
-
|
40
|
-
self.init_multistage()
|
18
|
+
class ROSCmdline(PluginCmdline):
|
19
|
+
"""Defines :term:`ROS1` common command line arguments."""
|
41
20
|
|
42
|
-
|
43
|
-
|
21
|
+
def __init__(
|
22
|
+
self,
|
23
|
+
parents: tp.List[argparse.ArgumentParser],
|
24
|
+
stages: tp.List[int],
|
25
|
+
) -> None:
|
26
|
+
super().__init__(parents, stages)
|
44
27
|
|
45
28
|
def init_multistage(self) -> None:
|
46
|
-
self.multistage.add_argument(
|
47
|
-
|
29
|
+
self.multistage.add_argument(
|
30
|
+
"--no-master-node",
|
31
|
+
help="""
|
48
32
|
|
49
33
|
Do not generate commands for/start a ROS1
|
50
34
|
master node on the SIERRA host
|
@@ -52,7 +36,7 @@ class ROSCmdline(cmd.BaseCmdline):
|
|
52
36
|
|
53
37
|
This is useful when:
|
54
38
|
|
55
|
-
- Using the :term:`ROS1+Robot`
|
39
|
+
- Using the :term:`ROS1+Robot` engine and
|
56
40
|
each robot outputs their own metrics to a
|
57
41
|
shared filesystem.
|
58
42
|
|
@@ -60,66 +44,53 @@ class ROSCmdline(cmd.BaseCmdline):
|
|
60
44
|
installed, and you are doing
|
61
45
|
testing/bringup of robots.
|
62
46
|
|
63
|
-
"""
|
64
|
-
|
47
|
+
"""
|
48
|
+
+ self.stage_usage_doc([1, 2]),
|
49
|
+
action="store_true",
|
50
|
+
)
|
65
51
|
|
66
52
|
def init_stage1(self) -> None:
|
67
53
|
# Experiment options
|
68
54
|
|
69
|
-
self.
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
class ROSCmdlineValidator():
|
113
|
-
"""
|
114
|
-
Perform checks on parsed ROS cmdline arguments.
|
115
|
-
"""
|
116
|
-
|
117
|
-
def __call__(self, args: argparse.Namespace) -> None:
|
118
|
-
assert args.robot is not None,\
|
119
|
-
"You must specify the --robot to use"
|
120
|
-
|
121
|
-
|
122
|
-
__api__ = [
|
123
|
-
'ROSCmdline',
|
124
|
-
'ROSCmdlineValidator'
|
55
|
+
self.stage1.add_argument(
|
56
|
+
"--exp-setup",
|
57
|
+
help="""
|
58
|
+
Defines experiment run length, ticks per second for the
|
59
|
+
experiment. See :ref:`usage/vars/expsetup` for a full
|
60
|
+
description.
|
61
|
+
"""
|
62
|
+
+ self.stage_usage_doc([1]),
|
63
|
+
default="exp_setup.T{0}.K{1}".format(
|
64
|
+
config.kROS["n_secs_per_run"],
|
65
|
+
config.kROS["n_ticks_per_sec"],
|
66
|
+
),
|
67
|
+
)
|
68
|
+
|
69
|
+
self.stage1.add_argument(
|
70
|
+
"--robot",
|
71
|
+
required=True,
|
72
|
+
help="""
|
73
|
+
The key name of the robot model, which must be present in the
|
74
|
+
appropriate section of ``{0}`` for the :term:`Project`. See
|
75
|
+
:ref:`tutorials/project/config` for details.
|
76
|
+
""".format(
|
77
|
+
config.kYAML.main
|
78
|
+
)
|
79
|
+
+ self.stage_usage_doc([1]),
|
80
|
+
)
|
81
|
+
|
82
|
+
|
83
|
+
def to_cmdopts(args: argparse.Namespace) -> types.Cmdopts:
|
84
|
+
"""Update cmdopts with ROS-specific cmdline options."""
|
85
|
+
return {
|
86
|
+
# multistage
|
87
|
+
"no_master_node": args.no_master_node,
|
88
|
+
# stage 1
|
89
|
+
"robot": args.robot,
|
90
|
+
"exp_setup": args.exp_setup,
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
__all__ = [
|
95
|
+
"ROSCmdline",
|
125
96
|
]
|
sierra/core/ros1/generators.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright 2021 John Harwell, All rights reserved.
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
|
-
"""Classes for generating XML changes common to all :term:`ROS1`
|
4
|
+
"""Classes for generating XML changes common to all :term:`ROS1` engines.
|
5
5
|
|
6
|
-
I.e., changes which are
|
6
|
+
I.e., changes which are engine-specific, but applicable to all projects using
|
7
7
|
ROS1.
|
8
8
|
|
9
9
|
"""
|
@@ -14,118 +14,105 @@ import pathlib
|
|
14
14
|
# 3rd party packages
|
15
15
|
|
16
16
|
# Project packages
|
17
|
-
from sierra.core.experiment import definition
|
17
|
+
from sierra.core.experiment import definition
|
18
|
+
from sierra.core.experiment import spec as expspec
|
18
19
|
import sierra.core.utils as scutils
|
19
20
|
from sierra.core import types, config
|
20
21
|
import sierra.core.ros1.variables.exp_setup as exp
|
22
|
+
from sierra.core import plugin as pm
|
21
23
|
|
24
|
+
_logger = logging.getLogger(__name__)
|
22
25
|
|
23
|
-
class ROSExpDefGenerator():
|
24
|
-
"""Generates XML changes to input files that common to all ROS experiments.
|
25
26
|
|
26
|
-
|
27
|
+
def for_all_exp(
|
28
|
+
spec: expspec.ExperimentSpec,
|
29
|
+
controller: str,
|
30
|
+
cmdopts: types.Cmdopts,
|
31
|
+
expdef_template_fpath: pathlib.Path,
|
32
|
+
) -> definition.BaseExpDef:
|
33
|
+
"""Generate XML changes to input files that common to all ROS experiments.
|
27
34
|
|
28
|
-
|
29
|
-
simulations only).
|
35
|
+
ROS1 requires up to 2 input files per run:
|
30
36
|
|
31
|
-
|
37
|
+
- The launch file containing robot definitions, world definitions (for
|
38
|
+
simulations only).
|
39
|
+
|
40
|
+
- The parameter file for project code (optional).
|
32
41
|
|
33
42
|
Putting everything in 1 file would require extensively using the ROS1
|
34
43
|
parameter server which does NOT accept parameters specified in XML--only
|
35
|
-
YAML.
|
44
|
+
YAML. So requiring some conventions on the .launch input file seemed more
|
36
45
|
reasonable.
|
46
|
+
"""
|
47
|
+
module = pm.pipeline.get_plugin_module(cmdopts["expdef"])
|
48
|
+
|
49
|
+
exp_def = module.ExpDef(input_fpath=expdef_template_fpath, write_config=None)
|
50
|
+
|
51
|
+
wr_config = definition.WriterConfig([])
|
52
|
+
|
53
|
+
if exp_def.has_element("./params"):
|
54
|
+
_logger.debug("Using shared XML parameter file")
|
55
|
+
wr_config.add(
|
56
|
+
{
|
57
|
+
"src_parent": ".",
|
58
|
+
"src_tag": "params",
|
59
|
+
"opath_leaf": config.kROS["param_file_ext"],
|
60
|
+
"new_children": None,
|
61
|
+
"new_children_parent": None,
|
62
|
+
"rename_to": None,
|
63
|
+
}
|
64
|
+
)
|
65
|
+
|
66
|
+
exp_def.write_config_set(wr_config)
|
67
|
+
|
68
|
+
# Add <master> tag
|
69
|
+
if not exp_def.has_element("./master"):
|
70
|
+
exp_def.element_add(".", "master", {})
|
71
|
+
if not exp_def.has_element("./master/group/[@ns='sierra']"):
|
72
|
+
exp_def.element_add("./master", "group", {"ns": "sierra"})
|
73
|
+
# Add <robot> tag
|
74
|
+
if not exp_def.has_element("./robot"):
|
75
|
+
exp_def.element_add(".", "robot", {})
|
76
|
+
if not exp_def.has_element("./robot/group/[@ns='sierra']"):
|
77
|
+
exp_def.element_add("./robot", "group", {"ns": "sierra"})
|
78
|
+
|
79
|
+
# Generate core experiment definitions
|
80
|
+
_generate_all_exp_experiment(exp_def, spec, cmdopts)
|
81
|
+
|
82
|
+
return exp_def
|
83
|
+
|
84
|
+
|
85
|
+
def _generate_all_exp_experiment(
|
86
|
+
exp_def: definition.BaseExpDef, spec: expspec.ExperimentSpec, cmdopts: types.Cmdopts
|
87
|
+
) -> None:
|
88
|
+
"""
|
89
|
+
Generate XML tag changes to setup basic experiment parameters.
|
90
|
+
|
91
|
+
Writes generated changes to the simulation definition pickle file.
|
92
|
+
"""
|
93
|
+
_logger.debug("Applying exp_setup=%s", cmdopts["exp_setup"])
|
94
|
+
robots_need_timekeeper = "ros1robot" in cmdopts["engine"]
|
37
95
|
|
38
|
-
|
96
|
+
# Barrier start not needed in simulation
|
97
|
+
use_barrier_start = (
|
98
|
+
"ros1robot" in cmdopts["engine"] and not cmdopts["no_master_node"]
|
99
|
+
)
|
39
100
|
|
40
|
-
|
41
|
-
|
101
|
+
setup = exp.factory(cmdopts["exp_setup"], use_barrier_start, robots_need_timekeeper)
|
102
|
+
_, adds, chgs = scutils.apply_to_expdef(setup, exp_def)
|
42
103
|
|
43
|
-
|
104
|
+
# Write setup info to file for later retrieval
|
105
|
+
scutils.pickle_modifications(adds, chgs, spec.exp_def_fpath)
|
44
106
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
self.kwargs = kwargs
|
55
|
-
self.ros_param_server = False
|
56
|
-
self.logger = logging.getLogger(__name__)
|
57
|
-
|
58
|
-
def generate(self) -> definition.XMLExpDef:
|
59
|
-
exp_def = definition.XMLExpDef(input_fpath=self.template_input_file)
|
60
|
-
wr_config = xml.WriterConfig([])
|
61
|
-
|
62
|
-
if exp_def.has_tag('./params'):
|
63
|
-
self.logger.debug("Using shared XML parameter file")
|
64
|
-
wr_config.add({
|
65
|
-
'src_parent': '.',
|
66
|
-
'src_tag': 'params',
|
67
|
-
'opath_leaf': config.kROS['param_file_ext'],
|
68
|
-
'create_tags': None,
|
69
|
-
'dest_parent': None,
|
70
|
-
'rename_to': None
|
71
|
-
})
|
72
|
-
|
73
|
-
else:
|
74
|
-
self.ros_param_server = True
|
75
|
-
|
76
|
-
exp_def.write_config_set(wr_config)
|
77
|
-
|
78
|
-
# Add <master> tag
|
79
|
-
if not exp_def.has_tag("./master"):
|
80
|
-
exp_def.tag_add(".",
|
81
|
-
"master",
|
82
|
-
{})
|
83
|
-
if not exp_def.has_tag("./master/group/[@ns='sierra']"):
|
84
|
-
exp_def.tag_add("./master",
|
85
|
-
"group",
|
86
|
-
{
|
87
|
-
'ns': 'sierra'
|
88
|
-
})
|
89
|
-
# Add <robot> tag
|
90
|
-
if not exp_def.has_tag("./robot"):
|
91
|
-
exp_def.tag_add(".",
|
92
|
-
"robot",
|
93
|
-
{})
|
94
|
-
if not exp_def.has_tag("./robot/group/[@ns='sierra']"):
|
95
|
-
exp_def.tag_add("./robot",
|
96
|
-
"group",
|
97
|
-
{
|
98
|
-
'ns': 'sierra'
|
99
|
-
})
|
100
|
-
|
101
|
-
# Generate core experiment definitions
|
102
|
-
self._generate_experiment(exp_def)
|
103
|
-
|
104
|
-
return exp_def
|
105
|
-
|
106
|
-
def _generate_experiment(self, exp_def: definition.XMLExpDef) -> None:
|
107
|
-
"""
|
108
|
-
Generate XML tag changes to setup basic experiment parameters.
|
109
|
-
|
110
|
-
Writes generated changes to the simulation definition pickle file.
|
111
|
-
"""
|
112
|
-
self.logger.debug("Applying exp_setup=%s", self.cmdopts['exp_setup'])
|
113
|
-
robots_need_timekeeper = 'ros1robot' in self.cmdopts['platform']
|
114
|
-
|
115
|
-
# Barrier start not needed in simulation
|
116
|
-
use_barrier_start = ('ros1robot' in self.cmdopts['platform'] and
|
117
|
-
not self.cmdopts["no_master_node"])
|
118
|
-
|
119
|
-
setup = exp.factory(self.cmdopts["exp_setup"],
|
120
|
-
use_barrier_start,
|
121
|
-
robots_need_timekeeper)()
|
122
|
-
rms, adds, chgs = scutils.apply_to_expdef(setup, exp_def)
|
123
|
-
|
124
|
-
# Write setup info to file for later retrieval
|
125
|
-
scutils.pickle_modifications(adds, chgs, self.spec.exp_def_fpath)
|
126
|
-
|
127
|
-
|
128
|
-
class ROSExpRunDefUniqueGenerator:
|
107
|
+
|
108
|
+
def for_single_exp_run(
|
109
|
+
exp_def: definition.BaseExpDef,
|
110
|
+
run_num: int,
|
111
|
+
run_output_path: pathlib.Path,
|
112
|
+
launch_stem_path: pathlib.Path,
|
113
|
+
random_seed: int,
|
114
|
+
cmdopts: types.Cmdopts,
|
115
|
+
) -> None:
|
129
116
|
"""
|
130
117
|
Generate XML changes unique to a experimental runs for ROS experiments.
|
131
118
|
|
@@ -135,80 +122,77 @@ class ROSExpRunDefUniqueGenerator:
|
|
135
122
|
|
136
123
|
- Unique parameter file for each: term: `Experimental Run`.
|
137
124
|
"""
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
'ROSExpDefGenerator',
|
213
|
-
'ROSExpRunDefUniqueGenerator'
|
214
|
-
]
|
125
|
+
_generate_single_exp_run_random(
|
126
|
+
exp_def, run_num, run_output_path, launch_stem_path, random_seed, cmdopts
|
127
|
+
)
|
128
|
+
|
129
|
+
_generate_single_exp_run_paramfile(
|
130
|
+
exp_def, run_num, run_output_path, launch_stem_path, random_seed, cmdopts
|
131
|
+
)
|
132
|
+
|
133
|
+
|
134
|
+
def _generate_single_exp_run_random(
|
135
|
+
exp_def: definition.BaseExpDef,
|
136
|
+
run_num: int,
|
137
|
+
run_output_path: pathlib.Path,
|
138
|
+
launch_stem_path: pathlib.Path,
|
139
|
+
random_seed: int,
|
140
|
+
cmdopts: types.Cmdopts,
|
141
|
+
) -> None:
|
142
|
+
"""Generate XML changes for random seeding for an experimental run."""
|
143
|
+
_logger.trace("Generating random seed changes for run%s", run_num) # type: ignore
|
144
|
+
|
145
|
+
# Master gets the random seed
|
146
|
+
exp_def.element_add(
|
147
|
+
"./master/group/[@ns='sierra']",
|
148
|
+
"param",
|
149
|
+
{"name": "experiment/random_seed", "value": str(random_seed)},
|
150
|
+
)
|
151
|
+
|
152
|
+
# Each robot gets the random seed
|
153
|
+
exp_def.element_add(
|
154
|
+
"./robot/group/[@ns='sierra']",
|
155
|
+
"param",
|
156
|
+
{"name": "experiment/random_seed", "value": str(random_seed)},
|
157
|
+
)
|
158
|
+
|
159
|
+
|
160
|
+
def _generate_single_exp_run_paramfile(
|
161
|
+
exp_def: definition.BaseExpDef,
|
162
|
+
run_num: int,
|
163
|
+
run_output_path: pathlib.Path,
|
164
|
+
launch_stem_path: pathlib.Path,
|
165
|
+
random_seed: int,
|
166
|
+
cmdopts: types.Cmdopts,
|
167
|
+
) -> None:
|
168
|
+
"""Generate XML changes for the parameter file for an experimental run."""
|
169
|
+
_logger.trace(
|
170
|
+
"Generating parameter file changes for run%s", run_num # type: ignore
|
171
|
+
)
|
172
|
+
|
173
|
+
param_file = launch_stem_path.with_suffix(config.kROS["param_file_ext"])
|
174
|
+
|
175
|
+
# Master node gets a copy of the parameter file
|
176
|
+
exp_def.element_add(
|
177
|
+
"./master/group/[@ns='sierra']",
|
178
|
+
"param",
|
179
|
+
{"name": "experiment/param_file", "value": str(param_file)},
|
180
|
+
)
|
181
|
+
|
182
|
+
# Each robot gets a copy of the parameter file
|
183
|
+
if not exp_def.has_element("./robot/group/[@ns='sierra']"):
|
184
|
+
exp_def.element_add(
|
185
|
+
"./robot",
|
186
|
+
"group",
|
187
|
+
{
|
188
|
+
"ns": "sierra",
|
189
|
+
},
|
190
|
+
)
|
191
|
+
exp_def.element_add(
|
192
|
+
"./robot/group/[@ns='sierra']",
|
193
|
+
"param",
|
194
|
+
{"name": "experiment/param_file", "value": str(param_file)},
|
195
|
+
)
|
196
|
+
|
197
|
+
|
198
|
+
__all__ = ["for_all_exp", "for_single_exp_run"]
|