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.
Files changed (254) hide show
  1. sierra/__init__.py +3 -3
  2. sierra/core/__init__.py +3 -3
  3. sierra/core/batchroot.py +223 -0
  4. sierra/core/cmdline.py +681 -1057
  5. sierra/core/compare.py +11 -0
  6. sierra/core/config.py +96 -88
  7. sierra/core/engine.py +306 -0
  8. sierra/core/execenv.py +380 -0
  9. sierra/core/expdef.py +11 -0
  10. sierra/core/experiment/__init__.py +1 -0
  11. sierra/core/experiment/bindings.py +150 -101
  12. sierra/core/experiment/definition.py +414 -245
  13. sierra/core/experiment/spec.py +83 -85
  14. sierra/core/exproot.py +44 -0
  15. sierra/core/generators/__init__.py +10 -0
  16. sierra/core/generators/experiment.py +528 -0
  17. sierra/core/generators/generator_factory.py +138 -137
  18. sierra/core/graphs/__init__.py +23 -0
  19. sierra/core/graphs/bcbridge.py +94 -0
  20. sierra/core/graphs/heatmap.py +245 -324
  21. sierra/core/graphs/pathset.py +27 -0
  22. sierra/core/graphs/schema.py +77 -0
  23. sierra/core/graphs/stacked_line.py +341 -0
  24. sierra/core/graphs/summary_line.py +506 -0
  25. sierra/core/logging.py +3 -2
  26. sierra/core/models/__init__.py +3 -1
  27. sierra/core/models/info.py +19 -0
  28. sierra/core/models/interface.py +52 -122
  29. sierra/core/pipeline/__init__.py +2 -5
  30. sierra/core/pipeline/pipeline.py +228 -126
  31. sierra/core/pipeline/stage1/__init__.py +10 -0
  32. sierra/core/pipeline/stage1/pipeline_stage1.py +45 -31
  33. sierra/core/pipeline/stage2/__init__.py +10 -0
  34. sierra/core/pipeline/stage2/pipeline_stage2.py +8 -11
  35. sierra/core/pipeline/stage2/runner.py +401 -0
  36. sierra/core/pipeline/stage3/__init__.py +12 -0
  37. sierra/core/pipeline/stage3/gather.py +321 -0
  38. sierra/core/pipeline/stage3/pipeline_stage3.py +37 -84
  39. sierra/core/pipeline/stage4/__init__.py +12 -2
  40. sierra/core/pipeline/stage4/pipeline_stage4.py +36 -354
  41. sierra/core/pipeline/stage5/__init__.py +12 -0
  42. sierra/core/pipeline/stage5/pipeline_stage5.py +33 -208
  43. sierra/core/pipeline/yaml.py +48 -0
  44. sierra/core/plugin.py +529 -62
  45. sierra/core/proc.py +11 -0
  46. sierra/core/prod.py +11 -0
  47. sierra/core/ros1/__init__.py +5 -1
  48. sierra/core/ros1/callbacks.py +22 -21
  49. sierra/core/ros1/cmdline.py +59 -88
  50. sierra/core/ros1/generators.py +159 -175
  51. sierra/core/ros1/variables/__init__.py +3 -0
  52. sierra/core/ros1/variables/exp_setup.py +122 -116
  53. sierra/core/startup.py +106 -76
  54. sierra/core/stat_kernels.py +4 -5
  55. sierra/core/storage.py +13 -32
  56. sierra/core/trampoline.py +30 -0
  57. sierra/core/types.py +116 -71
  58. sierra/core/utils.py +103 -106
  59. sierra/core/variables/__init__.py +1 -1
  60. sierra/core/variables/base_variable.py +12 -17
  61. sierra/core/variables/batch_criteria.py +387 -481
  62. sierra/core/variables/builtin.py +135 -0
  63. sierra/core/variables/exp_setup.py +19 -39
  64. sierra/core/variables/population_size.py +72 -76
  65. sierra/core/variables/variable_density.py +44 -68
  66. sierra/core/vector.py +1 -1
  67. sierra/main.py +256 -88
  68. sierra/plugins/__init__.py +119 -0
  69. sierra/plugins/compare/__init__.py +14 -0
  70. sierra/plugins/compare/graphs/__init__.py +19 -0
  71. sierra/plugins/compare/graphs/cmdline.py +120 -0
  72. sierra/plugins/compare/graphs/comparator.py +291 -0
  73. sierra/plugins/compare/graphs/inter_controller.py +531 -0
  74. sierra/plugins/compare/graphs/inter_scenario.py +297 -0
  75. sierra/plugins/compare/graphs/namecalc.py +53 -0
  76. sierra/plugins/compare/graphs/outputroot.py +73 -0
  77. sierra/plugins/compare/graphs/plugin.py +147 -0
  78. sierra/plugins/compare/graphs/preprocess.py +172 -0
  79. sierra/plugins/compare/graphs/schema.py +37 -0
  80. sierra/plugins/engine/__init__.py +14 -0
  81. sierra/plugins/engine/argos/__init__.py +18 -0
  82. sierra/plugins/{platform → engine}/argos/cmdline.py +144 -151
  83. sierra/plugins/{platform/argos/variables → engine/argos/generators}/__init__.py +5 -0
  84. sierra/plugins/engine/argos/generators/engine.py +394 -0
  85. sierra/plugins/engine/argos/plugin.py +393 -0
  86. sierra/plugins/{platform/argos/generators → engine/argos/variables}/__init__.py +5 -0
  87. sierra/plugins/engine/argos/variables/arena_shape.py +183 -0
  88. sierra/plugins/engine/argos/variables/cameras.py +240 -0
  89. sierra/plugins/engine/argos/variables/constant_density.py +112 -0
  90. sierra/plugins/engine/argos/variables/exp_setup.py +82 -0
  91. sierra/plugins/{platform → engine}/argos/variables/physics_engines.py +83 -87
  92. sierra/plugins/engine/argos/variables/population_constant_density.py +178 -0
  93. sierra/plugins/engine/argos/variables/population_size.py +115 -0
  94. sierra/plugins/engine/argos/variables/population_variable_density.py +123 -0
  95. sierra/plugins/engine/argos/variables/rendering.py +108 -0
  96. sierra/plugins/engine/ros1gazebo/__init__.py +18 -0
  97. sierra/plugins/engine/ros1gazebo/cmdline.py +175 -0
  98. sierra/plugins/{platform/ros1robot → engine/ros1gazebo}/generators/__init__.py +5 -0
  99. sierra/plugins/engine/ros1gazebo/generators/engine.py +125 -0
  100. sierra/plugins/engine/ros1gazebo/plugin.py +404 -0
  101. sierra/plugins/engine/ros1gazebo/variables/__init__.py +15 -0
  102. sierra/plugins/engine/ros1gazebo/variables/population_size.py +214 -0
  103. sierra/plugins/engine/ros1robot/__init__.py +18 -0
  104. sierra/plugins/engine/ros1robot/cmdline.py +159 -0
  105. sierra/plugins/{platform/ros1gazebo → engine/ros1robot}/generators/__init__.py +4 -0
  106. sierra/plugins/engine/ros1robot/generators/engine.py +95 -0
  107. sierra/plugins/engine/ros1robot/plugin.py +410 -0
  108. sierra/plugins/{hpc/local → engine/ros1robot/variables}/__init__.py +5 -0
  109. sierra/plugins/engine/ros1robot/variables/population_size.py +146 -0
  110. sierra/plugins/execenv/__init__.py +11 -0
  111. sierra/plugins/execenv/hpc/__init__.py +18 -0
  112. sierra/plugins/execenv/hpc/adhoc/__init__.py +18 -0
  113. sierra/plugins/execenv/hpc/adhoc/cmdline.py +30 -0
  114. sierra/plugins/execenv/hpc/adhoc/plugin.py +131 -0
  115. sierra/plugins/execenv/hpc/cmdline.py +137 -0
  116. sierra/plugins/execenv/hpc/local/__init__.py +18 -0
  117. sierra/plugins/execenv/hpc/local/cmdline.py +31 -0
  118. sierra/plugins/execenv/hpc/local/plugin.py +145 -0
  119. sierra/plugins/execenv/hpc/pbs/__init__.py +18 -0
  120. sierra/plugins/execenv/hpc/pbs/cmdline.py +30 -0
  121. sierra/plugins/execenv/hpc/pbs/plugin.py +121 -0
  122. sierra/plugins/execenv/hpc/slurm/__init__.py +18 -0
  123. sierra/plugins/execenv/hpc/slurm/cmdline.py +30 -0
  124. sierra/plugins/execenv/hpc/slurm/plugin.py +133 -0
  125. sierra/plugins/execenv/prefectserver/__init__.py +18 -0
  126. sierra/plugins/execenv/prefectserver/cmdline.py +66 -0
  127. sierra/plugins/execenv/prefectserver/dockerremote/__init__.py +18 -0
  128. sierra/plugins/execenv/prefectserver/dockerremote/cmdline.py +66 -0
  129. sierra/plugins/execenv/prefectserver/dockerremote/plugin.py +132 -0
  130. sierra/plugins/execenv/prefectserver/flow.py +66 -0
  131. sierra/plugins/execenv/prefectserver/local/__init__.py +18 -0
  132. sierra/plugins/execenv/prefectserver/local/cmdline.py +29 -0
  133. sierra/plugins/execenv/prefectserver/local/plugin.py +133 -0
  134. sierra/plugins/{hpc/adhoc → execenv/robot}/__init__.py +1 -0
  135. sierra/plugins/execenv/robot/turtlebot3/__init__.py +18 -0
  136. sierra/plugins/execenv/robot/turtlebot3/plugin.py +204 -0
  137. sierra/plugins/expdef/__init__.py +14 -0
  138. sierra/plugins/expdef/json/__init__.py +14 -0
  139. sierra/plugins/expdef/json/plugin.py +504 -0
  140. sierra/plugins/expdef/xml/__init__.py +14 -0
  141. sierra/plugins/expdef/xml/plugin.py +386 -0
  142. sierra/{core/hpc → plugins/proc}/__init__.py +1 -1
  143. sierra/plugins/proc/collate/__init__.py +15 -0
  144. sierra/plugins/proc/collate/cmdline.py +47 -0
  145. sierra/plugins/proc/collate/plugin.py +271 -0
  146. sierra/plugins/proc/compress/__init__.py +18 -0
  147. sierra/plugins/proc/compress/cmdline.py +47 -0
  148. sierra/plugins/proc/compress/plugin.py +123 -0
  149. sierra/plugins/proc/decompress/__init__.py +18 -0
  150. sierra/plugins/proc/decompress/plugin.py +96 -0
  151. sierra/plugins/proc/imagize/__init__.py +15 -0
  152. sierra/plugins/proc/imagize/cmdline.py +49 -0
  153. sierra/plugins/proc/imagize/plugin.py +270 -0
  154. sierra/plugins/proc/modelrunner/__init__.py +16 -0
  155. sierra/plugins/proc/modelrunner/plugin.py +250 -0
  156. sierra/plugins/proc/statistics/__init__.py +15 -0
  157. sierra/plugins/proc/statistics/cmdline.py +64 -0
  158. sierra/plugins/proc/statistics/plugin.py +390 -0
  159. sierra/plugins/{hpc → prod}/__init__.py +1 -0
  160. sierra/plugins/prod/graphs/__init__.py +18 -0
  161. sierra/plugins/prod/graphs/cmdline.py +269 -0
  162. sierra/plugins/prod/graphs/collate.py +279 -0
  163. sierra/plugins/prod/graphs/inter/__init__.py +13 -0
  164. sierra/plugins/prod/graphs/inter/generate.py +83 -0
  165. sierra/plugins/prod/graphs/inter/heatmap.py +86 -0
  166. sierra/plugins/prod/graphs/inter/line.py +134 -0
  167. sierra/plugins/prod/graphs/intra/__init__.py +15 -0
  168. sierra/plugins/prod/graphs/intra/generate.py +202 -0
  169. sierra/plugins/prod/graphs/intra/heatmap.py +74 -0
  170. sierra/plugins/prod/graphs/intra/line.py +114 -0
  171. sierra/plugins/prod/graphs/plugin.py +103 -0
  172. sierra/plugins/prod/graphs/targets.py +63 -0
  173. sierra/plugins/prod/render/__init__.py +18 -0
  174. sierra/plugins/prod/render/cmdline.py +72 -0
  175. sierra/plugins/prod/render/plugin.py +282 -0
  176. sierra/plugins/storage/__init__.py +5 -0
  177. sierra/plugins/storage/arrow/__init__.py +18 -0
  178. sierra/plugins/storage/arrow/plugin.py +38 -0
  179. sierra/plugins/storage/csv/__init__.py +9 -0
  180. sierra/plugins/storage/csv/plugin.py +12 -5
  181. sierra/version.py +3 -2
  182. sierra_research-1.5.0.dist-info/METADATA +238 -0
  183. sierra_research-1.5.0.dist-info/RECORD +186 -0
  184. {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info}/WHEEL +1 -2
  185. sierra/core/experiment/xml.py +0 -454
  186. sierra/core/generators/controller_generator_parser.py +0 -34
  187. sierra/core/generators/exp_creator.py +0 -351
  188. sierra/core/generators/exp_generators.py +0 -142
  189. sierra/core/graphs/scatterplot2D.py +0 -109
  190. sierra/core/graphs/stacked_line_graph.py +0 -251
  191. sierra/core/graphs/stacked_surface_graph.py +0 -220
  192. sierra/core/graphs/summary_line_graph.py +0 -371
  193. sierra/core/hpc/cmdline.py +0 -142
  194. sierra/core/models/graphs.py +0 -87
  195. sierra/core/pipeline/stage2/exp_runner.py +0 -286
  196. sierra/core/pipeline/stage3/imagizer.py +0 -149
  197. sierra/core/pipeline/stage3/run_collator.py +0 -317
  198. sierra/core/pipeline/stage3/statistics_calculator.py +0 -478
  199. sierra/core/pipeline/stage4/graph_collator.py +0 -320
  200. sierra/core/pipeline/stage4/inter_exp_graph_generator.py +0 -240
  201. sierra/core/pipeline/stage4/intra_exp_graph_generator.py +0 -317
  202. sierra/core/pipeline/stage4/model_runner.py +0 -168
  203. sierra/core/pipeline/stage4/rendering.py +0 -283
  204. sierra/core/pipeline/stage4/yaml_config_loader.py +0 -103
  205. sierra/core/pipeline/stage5/inter_scenario_comparator.py +0 -328
  206. sierra/core/pipeline/stage5/intra_scenario_comparator.py +0 -989
  207. sierra/core/platform.py +0 -493
  208. sierra/core/plugin_manager.py +0 -369
  209. sierra/core/root_dirpath_generator.py +0 -241
  210. sierra/plugins/hpc/adhoc/plugin.py +0 -125
  211. sierra/plugins/hpc/local/plugin.py +0 -81
  212. sierra/plugins/hpc/pbs/__init__.py +0 -9
  213. sierra/plugins/hpc/pbs/plugin.py +0 -126
  214. sierra/plugins/hpc/slurm/__init__.py +0 -9
  215. sierra/plugins/hpc/slurm/plugin.py +0 -130
  216. sierra/plugins/platform/__init__.py +0 -9
  217. sierra/plugins/platform/argos/__init__.py +0 -9
  218. sierra/plugins/platform/argos/generators/platform_generators.py +0 -383
  219. sierra/plugins/platform/argos/plugin.py +0 -337
  220. sierra/plugins/platform/argos/variables/arena_shape.py +0 -145
  221. sierra/plugins/platform/argos/variables/cameras.py +0 -243
  222. sierra/plugins/platform/argos/variables/constant_density.py +0 -136
  223. sierra/plugins/platform/argos/variables/exp_setup.py +0 -113
  224. sierra/plugins/platform/argos/variables/population_constant_density.py +0 -175
  225. sierra/plugins/platform/argos/variables/population_size.py +0 -102
  226. sierra/plugins/platform/argos/variables/population_variable_density.py +0 -132
  227. sierra/plugins/platform/argos/variables/rendering.py +0 -104
  228. sierra/plugins/platform/ros1gazebo/__init__.py +0 -9
  229. sierra/plugins/platform/ros1gazebo/cmdline.py +0 -213
  230. sierra/plugins/platform/ros1gazebo/generators/platform_generators.py +0 -137
  231. sierra/plugins/platform/ros1gazebo/plugin.py +0 -335
  232. sierra/plugins/platform/ros1gazebo/variables/__init__.py +0 -10
  233. sierra/plugins/platform/ros1gazebo/variables/population_size.py +0 -204
  234. sierra/plugins/platform/ros1robot/__init__.py +0 -9
  235. sierra/plugins/platform/ros1robot/cmdline.py +0 -175
  236. sierra/plugins/platform/ros1robot/generators/platform_generators.py +0 -112
  237. sierra/plugins/platform/ros1robot/plugin.py +0 -373
  238. sierra/plugins/platform/ros1robot/variables/__init__.py +0 -10
  239. sierra/plugins/platform/ros1robot/variables/population_size.py +0 -146
  240. sierra/plugins/robot/__init__.py +0 -9
  241. sierra/plugins/robot/turtlebot3/__init__.py +0 -9
  242. sierra/plugins/robot/turtlebot3/plugin.py +0 -194
  243. sierra_research-1.3.11.data/data/share/man/man1/sierra-cli.1 +0 -2349
  244. sierra_research-1.3.11.data/data/share/man/man7/sierra-examples.7 +0 -508
  245. sierra_research-1.3.11.data/data/share/man/man7/sierra-exec-envs.7 +0 -331
  246. sierra_research-1.3.11.data/data/share/man/man7/sierra-glossary.7 +0 -285
  247. sierra_research-1.3.11.data/data/share/man/man7/sierra-platforms.7 +0 -358
  248. sierra_research-1.3.11.data/data/share/man/man7/sierra-usage.7 +0 -729
  249. sierra_research-1.3.11.data/data/share/man/man7/sierra.7 +0 -78
  250. sierra_research-1.3.11.dist-info/METADATA +0 -492
  251. sierra_research-1.3.11.dist-info/RECORD +0 -133
  252. sierra_research-1.3.11.dist-info/top_level.txt +0 -1
  253. {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info}/entry_points.txt +0 -0
  254. {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info/licenses}/LICENSE +0 -0
@@ -2,9 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
4
  #
5
- """Common classes and callbacks :term:`Platforms <Platform>` using :term:`ROS1`.
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 xml, definition
14
+ from sierra.core.experiment import definition
17
15
 
18
16
 
19
- def population_size_from_pickle(adds_def: tp.Union[xml.AttrChangeSet,
20
- xml.TagAddList],
21
- main_config: types.YAMLDict,
22
- cmdopts: types.Cmdopts) -> int:
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 'name' in add.attr and 'n_robots' in add.attr['name']:
25
- return int(add.attr['value'])
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(exp_def: definition.XMLExpDef,
31
- main_config: types.YAMLDict,
32
- cmdopts: types.Cmdopts) -> int:
33
- return population_size_from_pickle(exp_def.tag_adds, main_config, cmdopts)
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
- cmdopts: types.Cmdopts) -> str:
38
- return main_config['ros']['robots'][cmdopts['robot']]['prefix']
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
- __api__ = [
42
- 'population_size_from_pickle',
43
- 'population_size_from_def',
44
- 'robot_prefix_extract'
42
+ __all__ = [
43
+ "population_size_from_pickle",
44
+ "population_size_from_def",
45
+ "robot_prefix_extract",
45
46
  ]
@@ -2,9 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
4
  #
5
- """Common cmdline classes :term:`Platforms <Platform>` using :term:`ROS1`.
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
- import sierra.core.cmdline as cmd
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
- def init_cli(self, stages: tp.List[int]) -> None:
39
- if -1 in stages:
40
- self.init_multistage()
18
+ class ROSCmdline(PluginCmdline):
19
+ """Defines :term:`ROS1` common command line arguments."""
41
20
 
42
- if 1 in stages:
43
- self.init_stage1()
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("--no-master-node",
47
- help="""
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` platform and
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
- """ + self.stage_usage_doc([1, 2]),
64
- action='store_true')
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.stage1_exp.add_argument("--exp-setup",
70
- help="""
71
-
72
- Defines experiment run length, ticks per
73
- second for the experiment, # of datapoints
74
- to capture/capture interval for each
75
- simulation. See :ref:`ln-sierra-vars-expsetup` for
76
- a full description.
77
-
78
- """ + self.stage_usage_doc([1]),
79
- default="exp_setup.T{0}.K{1}.N{2}".format(
80
- config.kROS['n_secs_per_run'],
81
- config.kROS['n_ticks_per_sec'],
82
- config.kExperimentalRunData['n_datapoints_1D']))
83
-
84
- self.stage1_exp.add_argument("--robot",
85
- help="""
86
-
87
- The key name of the robot model, which must
88
- be present in the appropriate section of
89
- ``{0}`` for the :term:`Project`. See
90
- :ref:`ln-sierra-tutorials-project-main-config`
91
- for details.
92
-
93
- """.format(config.kYAML.main) + self.stage_usage_doc([1]))
94
-
95
- @staticmethod
96
- def cmdopts_update(cli_args, cmdopts: types.Cmdopts) -> None:
97
- """Update cmdopts with ROS-specific cmdline options.
98
- """
99
- updates = {
100
- # multistagev
101
- 'no_master_node': cli_args.no_master_node,
102
-
103
- # stage 1
104
- 'robot': cli_args.robot,
105
- 'exp_setup': cli_args.exp_setup,
106
-
107
- }
108
-
109
- cmdopts.update(updates)
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
  ]
@@ -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` platforms.
4
+ """Classes for generating XML changes common to all :term:`ROS1` engines.
5
5
 
6
- I.e., changes which are platform-specific, but applicable to all projects using
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, spec, xml
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
- ROS1 requires up to 2 input files per run:
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
- - The launch file containing robot definitions, world definitions (for
29
- simulations only).
35
+ ROS1 requires up to 2 input files per run:
30
36
 
31
- - The parameter file for project code (optional).
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. So requiring some conventions on the .launch input file seemed more
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
- Attributes:
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
- controller: The controller used for the experiment.
41
- cmdopts: Dictionary of parsed cmdline parameters.
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
- def __init__(self,
46
- exp_spec: spec.ExperimentSpec,
47
- controller: str,
48
- cmdopts: types.Cmdopts,
49
- **kwargs) -> None:
50
- self.controller = controller
51
- self.spec = exp_spec
52
- self.cmdopts = cmdopts
53
- self.template_input_file = kwargs['template_input_file']
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
- def __init__(self,
140
- run_num: int,
141
- run_output_path: pathlib.Path,
142
- launch_stem_path: pathlib.Path,
143
- random_seed: int,
144
- cmdopts: types.Cmdopts) -> None:
145
-
146
- self.run_output_path = run_output_path
147
- self.launch_stem_path = launch_stem_path
148
- self.random_seed = random_seed
149
- self.cmdopts = cmdopts
150
- self.run_num = run_num
151
- self.logger = logging.getLogger(__name__)
152
-
153
- def generate(self, exp_def: definition.XMLExpDef):
154
- return exp_def
155
-
156
- def generate_random(self, exp_def: definition.XMLExpDef) -> None:
157
- """Generate XML changes for random seeding for an experimental run.
158
-
159
- """
160
- self.logger.trace("Generating random seed changes for run%s", # type: ignore
161
- self.run_num)
162
-
163
- # Master gets the random seed
164
- exp_def.tag_add("./master/group/[@ns='sierra']",
165
- "param",
166
- {
167
- "name": "experiment/random_seed",
168
- "value": str(self.random_seed)
169
- })
170
-
171
- # Each robot gets the random seed
172
- exp_def.tag_add("./robot/group/[@ns='sierra']",
173
- "param",
174
- {
175
- "name": "experiment/random_seed",
176
- "value": str(self.random_seed)
177
- })
178
-
179
- def generate_paramfile(self, exp_def: definition.XMLExpDef) -> None:
180
- """Generate XML changes for the parameter file for an experimental run.
181
-
182
- """
183
- self.logger.trace("Generating parameter file changes for run%s", # type: ignore
184
- self.run_num)
185
-
186
- param_file = self.launch_stem_path.with_suffix(config.kROS['param_file_ext'])
187
-
188
- # Master node gets a copy of the parameter file
189
- exp_def.tag_add("./master/group/[@ns='sierra']",
190
- "param",
191
- {
192
- "name": "experiment/param_file",
193
- "value": str(param_file)
194
- })
195
-
196
- # Each robot gets a copy of the parameter file
197
- if not exp_def.has_tag("./robot/group/[@ns='sierra']"):
198
- exp_def.tag_add("./robot",
199
- "group",
200
- {
201
- "ns": "sierra",
202
- })
203
- exp_def.tag_add("./robot/group/[@ns='sierra']",
204
- "param",
205
- {
206
- "name": "experiment/param_file",
207
- "value": str(param_file)
208
- })
209
-
210
-
211
- __api__ = [
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"]
@@ -1,6 +1,9 @@
1
1
  # Copyright 2022 John Harwell, All rights reserved.
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
+ """
5
+ Common variables module for the :term:`ROS1` engine.
6
+ """
4
7
 
5
8
  # Core packages
6
9