sierra-research 1.3.6__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.6.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 -249
- sierra/core/graphs/stacked_surface_graph.py +0 -220
- sierra/core/graphs/summary_line_graph.py +0 -369
- 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 -319
- 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.6.data/data/share/man/man1/sierra-cli.1 +0 -2349
- sierra_research-1.3.6.data/data/share/man/man7/sierra-examples.7 +0 -488
- sierra_research-1.3.6.data/data/share/man/man7/sierra-exec-envs.7 +0 -331
- sierra_research-1.3.6.data/data/share/man/man7/sierra-glossary.7 +0 -285
- sierra_research-1.3.6.data/data/share/man/man7/sierra-platforms.7 +0 -358
- sierra_research-1.3.6.data/data/share/man/man7/sierra-usage.7 +0 -725
- sierra_research-1.3.6.data/data/share/man/man7/sierra.7 +0 -78
- sierra_research-1.3.6.dist-info/METADATA +0 -500
- sierra_research-1.3.6.dist-info/RECORD +0 -133
- sierra_research-1.3.6.dist-info/top_level.txt +0 -1
- {sierra_research-1.3.6.dist-info → sierra_research-1.5.0.dist-info}/entry_points.txt +0 -0
- {sierra_research-1.3.6.dist-info → sierra_research-1.5.0.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
# Copyright 2021 John Harwell, All rights reserved.
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
#
|
5
|
+
"""Classes for the variable population density batch criteria.
|
6
|
+
|
7
|
+
See :ref:`plugins/engine/argos/bc/population-variable-density` for usage
|
8
|
+
documentation.
|
9
|
+
|
10
|
+
"""
|
11
|
+
|
12
|
+
# Core packages
|
13
|
+
import typing as tp
|
14
|
+
import logging
|
15
|
+
import pathlib
|
16
|
+
|
17
|
+
# 3rd party packages
|
18
|
+
import implements
|
19
|
+
|
20
|
+
# Project packages
|
21
|
+
from sierra.core.variables import variable_density as vd
|
22
|
+
from sierra.core.vector import Vector3D
|
23
|
+
from sierra.core.experiment import definition
|
24
|
+
from sierra.core import types, utils
|
25
|
+
from sierra.core.graphs import bcbridge
|
26
|
+
|
27
|
+
|
28
|
+
@implements.implements(bcbridge.IGraphable)
|
29
|
+
class PopulationVariableDensity(vd.VariableDensity):
|
30
|
+
"""Defines XML changes for variable population density within a single arena.
|
31
|
+
|
32
|
+
This class is a base class which should (almost) never be used on its
|
33
|
+
own. Instead, the ``factory()`` function should be used to dynamically
|
34
|
+
create derived classes expressing the user's desired density ranges.
|
35
|
+
|
36
|
+
"""
|
37
|
+
|
38
|
+
def __init__(self, *args, **kwargs) -> None:
|
39
|
+
vd.VariableDensity.__init__(self, *args, **kwargs)
|
40
|
+
self.already_added = False
|
41
|
+
self.logger = logging.getLogger(__name__)
|
42
|
+
|
43
|
+
def gen_attr_changelist(self) -> tp.List[definition.AttrChangeSet]:
|
44
|
+
"""Generate XML modifications to achieve the desired population densities.
|
45
|
+
|
46
|
+
Robots are approximated as point masses.
|
47
|
+
|
48
|
+
"""
|
49
|
+
if not self.already_added:
|
50
|
+
for density in self.densities:
|
51
|
+
# ARGoS won't start if there are 0 robots, so you always
|
52
|
+
# need to put at least 1.
|
53
|
+
n_agents = int(self.extent.area() * (density / 100.0))
|
54
|
+
if n_agents == 0:
|
55
|
+
n_agents = 1
|
56
|
+
self.logger.warning(
|
57
|
+
"n_agents set to 1 even though \
|
58
|
+
calculated as 0 for area=%d,density=%s",
|
59
|
+
self.extent.area(),
|
60
|
+
density,
|
61
|
+
)
|
62
|
+
changeset = definition.AttrChangeSet(
|
63
|
+
definition.AttrChange(
|
64
|
+
".//arena/distribute/entity", "quantity", str(n_agents)
|
65
|
+
)
|
66
|
+
)
|
67
|
+
self.attr_changes.append(changeset)
|
68
|
+
self.logger.debug(
|
69
|
+
"Calculated swarm size=%d for extent=%s,density=%s",
|
70
|
+
n_agents,
|
71
|
+
str(self.extent),
|
72
|
+
density,
|
73
|
+
)
|
74
|
+
|
75
|
+
self.already_added = True
|
76
|
+
|
77
|
+
return self.attr_changes
|
78
|
+
|
79
|
+
def graph_info(
|
80
|
+
self,
|
81
|
+
cmdopts: types.Cmdopts,
|
82
|
+
batch_output_root: tp.Optional[pathlib.Path] = None,
|
83
|
+
exp_names: tp.Optional[tp.List[str]] = None,
|
84
|
+
) -> bcbridge.GraphInfo:
|
85
|
+
info = bcbridge.GraphInfo(
|
86
|
+
cmdopts,
|
87
|
+
batch_output_root,
|
88
|
+
exp_names if exp_names else self.gen_exp_names(),
|
89
|
+
)
|
90
|
+
|
91
|
+
info.xticks = [
|
92
|
+
p / self.extent.area()
|
93
|
+
for p in self.populations(info.cmdopts, info.exp_names)
|
94
|
+
]
|
95
|
+
info.xticklabels = list(map(lambda x: str(round(x, 4)), info.xticks))
|
96
|
+
info.xlabel = "Population Density"
|
97
|
+
return info
|
98
|
+
|
99
|
+
def n_agents(self, exp_num: int) -> int:
|
100
|
+
return int(self.extent.area() * self.densities[exp_num] / 100.0)
|
101
|
+
|
102
|
+
|
103
|
+
def factory(
|
104
|
+
cli_arg: str,
|
105
|
+
main_config: types.YAMLDict,
|
106
|
+
cmdopts: types.Cmdopts,
|
107
|
+
batch_input_root: pathlib.Path,
|
108
|
+
**kwargs,
|
109
|
+
) -> PopulationVariableDensity:
|
110
|
+
"""
|
111
|
+
Create a :class:`PopulationVariableDensity` derived class.
|
112
|
+
"""
|
113
|
+
densities = vd.parse(cli_arg)
|
114
|
+
kw = utils.gen_scenario_spec(cmdopts, **kwargs)
|
115
|
+
|
116
|
+
extent = utils.ArenaExtent(Vector3D(kw["arena_x"], kw["arena_y"], kw["arena_z"]))
|
117
|
+
|
118
|
+
return PopulationVariableDensity(
|
119
|
+
cli_arg, main_config, batch_input_root, densities, extent
|
120
|
+
)
|
121
|
+
|
122
|
+
|
123
|
+
__all__ = ["PopulationVariableDensity"]
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# Copyright 2021 John Harwell, All rights reserved.
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
|
5
|
+
"""
|
6
|
+
ARGoS headless QT rendering configuration.
|
7
|
+
"""
|
8
|
+
|
9
|
+
# Core packages
|
10
|
+
import typing as tp
|
11
|
+
|
12
|
+
# 3rd party packages
|
13
|
+
import implements
|
14
|
+
|
15
|
+
# Project packages
|
16
|
+
from sierra.core.variables.base_variable import IBaseVariable
|
17
|
+
from sierra.core.experiment import definition
|
18
|
+
import sierra.core.config
|
19
|
+
from sierra.core import types
|
20
|
+
|
21
|
+
import sierra.plugins.engine.argos.variables.exp_setup as exp
|
22
|
+
|
23
|
+
|
24
|
+
@implements.implements(IBaseVariable)
|
25
|
+
class ARGoSQTHeadlessRendering:
|
26
|
+
"""
|
27
|
+
Sets up ARGoS headless rendering with QT.
|
28
|
+
|
29
|
+
Attributes:
|
30
|
+
tsetup: Simulation time definitions.
|
31
|
+
|
32
|
+
extents: List of (X,Y,Zs) tuple of dimensions of area to assign to
|
33
|
+
engines of the specified type.
|
34
|
+
"""
|
35
|
+
|
36
|
+
kFrameSize = "1600x1200"
|
37
|
+
kQUALITY = 100
|
38
|
+
kFRAME_RATE = 10
|
39
|
+
|
40
|
+
def __init__(self, setup: exp.ExpSetup) -> None:
|
41
|
+
self.setup = setup
|
42
|
+
self.element_adds = [] # type: tp.List[definition.ElementAddList]
|
43
|
+
|
44
|
+
def gen_attr_changelist(self) -> tp.List[definition.AttrChangeSet]:
|
45
|
+
"""
|
46
|
+
No effect.
|
47
|
+
|
48
|
+
All tags/attributes are either deleted or added.
|
49
|
+
"""
|
50
|
+
return []
|
51
|
+
|
52
|
+
def gen_tag_rmlist(self) -> tp.List[definition.ElementRmList]:
|
53
|
+
"""Remove the ``<qt_opengl>`` tag if it exists.
|
54
|
+
|
55
|
+
Obviously you *must* call this function BEFORE adding new definitions.
|
56
|
+
|
57
|
+
"""
|
58
|
+
return [
|
59
|
+
definition.ElementRmList(
|
60
|
+
definition.ElementRm("./visualization", "qt-opengl")
|
61
|
+
)
|
62
|
+
]
|
63
|
+
|
64
|
+
def gen_element_addlist(self) -> tp.List[definition.ElementAddList]:
|
65
|
+
if not self.element_adds:
|
66
|
+
self.element_adds = [
|
67
|
+
definition.ElementAddList(
|
68
|
+
definition.ElementAdd(".", "visualization", {}, False),
|
69
|
+
definition.ElementAdd(
|
70
|
+
"./visualization", "qt-opengl", {"autoplay": "true"}, False
|
71
|
+
),
|
72
|
+
definition.ElementAdd(
|
73
|
+
"./visualization/qt-opengl",
|
74
|
+
"frame_grabbing",
|
75
|
+
{
|
76
|
+
"directory": "frames",
|
77
|
+
"base_name": "frame_",
|
78
|
+
"format": sierra.core.config.kStaticImageType,
|
79
|
+
"headless_grabbing": "true",
|
80
|
+
"headless_frame_size": "{0}".format(self.kFrameSize),
|
81
|
+
"headless_frame_rate": "{0}".format(self.kFRAME_RATE),
|
82
|
+
},
|
83
|
+
False,
|
84
|
+
),
|
85
|
+
definition.ElementAdd(
|
86
|
+
"visualization/qt-opengl",
|
87
|
+
"user_functions",
|
88
|
+
{"label": "__EMPTY__"},
|
89
|
+
False,
|
90
|
+
),
|
91
|
+
)
|
92
|
+
]
|
93
|
+
|
94
|
+
return self.element_adds
|
95
|
+
|
96
|
+
def gen_files(self) -> None:
|
97
|
+
pass
|
98
|
+
|
99
|
+
|
100
|
+
def factory(cmdopts: types.Cmdopts) -> ARGoSQTHeadlessRendering:
|
101
|
+
"""Set up QT headless rendering for the specified experimental setup."""
|
102
|
+
|
103
|
+
return ARGoSQTHeadlessRendering(exp.factory(cmdopts["exp_setup"]))
|
104
|
+
|
105
|
+
|
106
|
+
__all__ = [
|
107
|
+
"ARGoSQTHeadlessRendering",
|
108
|
+
]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2021 John Harwell, All rights reserved.
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
"""
|
5
|
+
Container module for the :term:`ROS1+Gazebo` engine.
|
6
|
+
|
7
|
+
See :ref:`plugins/engine/ros1gazebo`.
|
8
|
+
"""
|
9
|
+
|
10
|
+
# Core packages
|
11
|
+
|
12
|
+
# 3rd party packages
|
13
|
+
|
14
|
+
# Project packages
|
15
|
+
|
16
|
+
|
17
|
+
def sierra_plugin_type() -> str:
|
18
|
+
return "pipeline"
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# Copyright 2021 John Harwell, All rights reserved.
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
#
|
5
|
+
"""
|
6
|
+
Command line parsing and validation for the :term:`ROS1+Gazebo` engine.
|
7
|
+
"""
|
8
|
+
|
9
|
+
# Core packages
|
10
|
+
import typing as tp
|
11
|
+
import argparse
|
12
|
+
|
13
|
+
# 3rd party packages
|
14
|
+
|
15
|
+
# Project packages
|
16
|
+
from sierra.core import types
|
17
|
+
from sierra.core import config
|
18
|
+
from sierra.core import ros1
|
19
|
+
from sierra.plugins import PluginCmdline
|
20
|
+
|
21
|
+
|
22
|
+
class EngineCmdline(ros1.cmdline.ROSCmdline):
|
23
|
+
"""Defines :term:`ROS1+Gazebo` extensions to :class:`~sierra.core.cmdline.CoreCmdline`."""
|
24
|
+
|
25
|
+
def __init__(
|
26
|
+
self,
|
27
|
+
parents: tp.List[argparse.ArgumentParser],
|
28
|
+
stages: tp.List[int],
|
29
|
+
) -> None:
|
30
|
+
super().__init__(parents, stages)
|
31
|
+
|
32
|
+
def init_stage1(self) -> None:
|
33
|
+
super().init_stage1()
|
34
|
+
# Experiment options
|
35
|
+
positions_omitted_doc = (
|
36
|
+
"If omitted: effective arena dimensions must "
|
37
|
+
"be given as part of ``--scenario``."
|
38
|
+
)
|
39
|
+
|
40
|
+
self.stage1.add_argument(
|
41
|
+
"--robot-positions",
|
42
|
+
help="""
|
43
|
+
A list of space-separated "X,Y,Z" tuples (no quotes) passed on
|
44
|
+
the command line as valid starting positions for the robots
|
45
|
+
within the world.
|
46
|
+
"""
|
47
|
+
+ self.stage_usage_doc([1], positions_omitted_doc),
|
48
|
+
nargs="+",
|
49
|
+
default=[],
|
50
|
+
)
|
51
|
+
|
52
|
+
# Physics engines options
|
53
|
+
self.stage1.add_argument(
|
54
|
+
"--physics-engine-type",
|
55
|
+
choices=["ode", "bullet", "dart", "simbody"],
|
56
|
+
help="""
|
57
|
+
The type of 3D physics engine to use for managing spatial
|
58
|
+
extents within the arena, choosing one of the types that
|
59
|
+
:term:`Gazebo` supports. A single engine instance is used to
|
60
|
+
manage all physics in the arena.
|
61
|
+
"""
|
62
|
+
+ self.stage_usage_doc([1]),
|
63
|
+
default="ode",
|
64
|
+
)
|
65
|
+
|
66
|
+
self.stage1.add_argument(
|
67
|
+
"--physics-iter-per-tick",
|
68
|
+
type=int,
|
69
|
+
help="""
|
70
|
+
The # of iterations all physics engines should perform per tick
|
71
|
+
each time the controller loops are run (the # of ticks per
|
72
|
+
second for controller control loops is set via
|
73
|
+
``--exp-setup``).
|
74
|
+
"""
|
75
|
+
+ self.stage_usage_doc([1]),
|
76
|
+
default=config.kGazebo["physics_iter_per_tick"],
|
77
|
+
)
|
78
|
+
|
79
|
+
self.stage1.add_argument(
|
80
|
+
"--physics-n-threads",
|
81
|
+
type=int,
|
82
|
+
help="""
|
83
|
+
Gazebo can group non-interacting entities into computational
|
84
|
+
"islands" and do the physics updates for those islands in
|
85
|
+
parallel each timestep (islands) are recomputed after each
|
86
|
+
timestep). Gazebo can also parallelize the computation of
|
87
|
+
velocity/position updates with the computation of resolving
|
88
|
+
collisions (i.e., the timestep impulse results in one entity
|
89
|
+
"inside" another). You can assign multiple threads to a pool
|
90
|
+
for cumulative use for these two parallelization methods
|
91
|
+
(threads will be allocated evenly between them). The point at
|
92
|
+
which adding more threads will start to DECREASE performance
|
93
|
+
depends on the complexity of your world, the number and type of
|
94
|
+
robots in it, etc., so don't just set this parameter to the #
|
95
|
+
of cores for your machine as a default.
|
96
|
+
|
97
|
+
From the Gazebo Parallel Physics Report, setting the pool size
|
98
|
+
to the # robots/# joint trees in your simulation usually gives
|
99
|
+
good results, as long as you have more cores available than you
|
100
|
+
allocate to this pool (Gazebo has other threads too).
|
101
|
+
|
102
|
+
This only applies if ``--physics-engine-type``\\=ode.
|
103
|
+
|
104
|
+
A value of 0=no threads.
|
105
|
+
"""
|
106
|
+
+ self.stage_usage_doc([1]),
|
107
|
+
default=0,
|
108
|
+
)
|
109
|
+
|
110
|
+
self.stage1.add_argument(
|
111
|
+
"--physics-ec-threadpool",
|
112
|
+
type=int,
|
113
|
+
help="""
|
114
|
+
Gazebo can parallelize the computation of velocity/position
|
115
|
+
updates with the computation of resolving collisions (i.e., the
|
116
|
+
timestep impulse results in one entity "inside" another). You
|
117
|
+
can assign multiple threads to a pool for cumulative use for
|
118
|
+
this purpose. The point at which adding more threads will
|
119
|
+
start to DECREASE performance depends on the complexity of your
|
120
|
+
world, the number and type of robots in it, etc., so don't just
|
121
|
+
set this parameter to the # of cores for your machine as a
|
122
|
+
default.
|
123
|
+
|
124
|
+
From the Gazebo Parallel Physics Report, setting the pool size
|
125
|
+
to the # robots/#joint trees in your simulation usually gives
|
126
|
+
good results, as long as you have more cores than than you
|
127
|
+
allocate to physics (Gazebo has other threads too).
|
128
|
+
|
129
|
+
This only applies if ``--physics-engine-type``\\=ode.
|
130
|
+
|
131
|
+
A value of 0=no threads.
|
132
|
+
"""
|
133
|
+
+ self.stage_usage_doc([1]),
|
134
|
+
default=0,
|
135
|
+
)
|
136
|
+
|
137
|
+
|
138
|
+
def build(
|
139
|
+
parents: tp.List[argparse.ArgumentParser], stages: tp.List[int]
|
140
|
+
) -> PluginCmdline:
|
141
|
+
"""
|
142
|
+
Get a cmdline parser supporting the :term:`ROS1+Gazebo` engine.
|
143
|
+
|
144
|
+
Contains:
|
145
|
+
|
146
|
+
- :class:`~sierra.core.ros1.cmdline.ROSCmdline` (ROS1 common)
|
147
|
+
|
148
|
+
- :class:`~sierra.plugins.engine.ros1gazebo.cmdline.EngineCmdline`
|
149
|
+
(ROS1+Gazebo)
|
150
|
+
"""
|
151
|
+
return EngineCmdline(parents=parents, stages=stages)
|
152
|
+
|
153
|
+
|
154
|
+
def to_cmdopts(args: argparse.Namespace) -> types.Cmdopts:
|
155
|
+
"""Update cmdopts with ROS1+Gazebo-specific cmdline options."""
|
156
|
+
opts = ros1.cmdline.to_cmdopts(args)
|
157
|
+
|
158
|
+
for_self = {
|
159
|
+
# stage 1
|
160
|
+
"robot_positions": args.robot_positions,
|
161
|
+
"physics_n_engines": 1, # Always 1 for gazebo...
|
162
|
+
"physics_n_threads": args.physics_n_threads,
|
163
|
+
"physics_engine_type": args.physics_engine_type,
|
164
|
+
"physics_iter_per_tick": args.physics_iter_per_tick,
|
165
|
+
}
|
166
|
+
|
167
|
+
opts |= for_self
|
168
|
+
return opts
|
169
|
+
|
170
|
+
|
171
|
+
def sphinx_cmdline_stage1():
|
172
|
+
return EngineCmdline([], [1]).parser
|
173
|
+
|
174
|
+
|
175
|
+
__all__ = ["EngineCmdline"]
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# Copyright 2021 John Harwell, All rights reserved.
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
"""Classes for generating common XML modifications for :term:`ROS1+Gazebo`.
|
5
|
+
|
6
|
+
I.e., changes which are engine-specific, but applicable to all projects using
|
7
|
+
the engine.
|
8
|
+
|
9
|
+
"""
|
10
|
+
# Core packages
|
11
|
+
import logging
|
12
|
+
import pathlib
|
13
|
+
|
14
|
+
# 3rd party packages
|
15
|
+
|
16
|
+
# Project packages
|
17
|
+
from sierra.core.experiment import spec as expspec
|
18
|
+
from sierra.core.experiment import definition
|
19
|
+
from sierra.core import types, ros1, config
|
20
|
+
|
21
|
+
_logger = logging.getLogger(__name__)
|
22
|
+
|
23
|
+
|
24
|
+
def for_all_exp(spec: expspec.ExperimentSpec,
|
25
|
+
controller: str,
|
26
|
+
cmdopts: types.Cmdopts,
|
27
|
+
expdef_template_fpath: pathlib.Path) -> definition.BaseExpDef:
|
28
|
+
"""Generate XML modifications common to all ROS1+Gazebo experiments."""
|
29
|
+
exp_def = ros1.generators.for_all_exp(spec,
|
30
|
+
controller,
|
31
|
+
cmdopts,
|
32
|
+
expdef_template_fpath)
|
33
|
+
|
34
|
+
exp_def.write_config.add({
|
35
|
+
'src_parent': ".",
|
36
|
+
'src_tag': "master",
|
37
|
+
'opath_leaf': "_master" + config.kROS['launch_file_ext'],
|
38
|
+
'new_children': None,
|
39
|
+
'new_children_parent': None,
|
40
|
+
'rename_to': 'launch'
|
41
|
+
})
|
42
|
+
|
43
|
+
exp_def.write_config.add({
|
44
|
+
'src_parent': ".",
|
45
|
+
'src_tag': "robot",
|
46
|
+
'opath_leaf': "_robots" + config.kROS['launch_file_ext'],
|
47
|
+
'new_children': None,
|
48
|
+
'new_children_parent': None,
|
49
|
+
'rename_to': 'launch'
|
50
|
+
})
|
51
|
+
|
52
|
+
# Setup gazebo experiment
|
53
|
+
_generate_all_exp_gazebo_core(exp_def)
|
54
|
+
|
55
|
+
# Setup gazebo visualization
|
56
|
+
_generate_all_exp_gazebo_vis(exp_def)
|
57
|
+
|
58
|
+
return exp_def
|
59
|
+
|
60
|
+
|
61
|
+
def _generate_all_exp_gazebo_core(exp_def: definition.BaseExpDef) -> None:
|
62
|
+
"""
|
63
|
+
Generate XML tag changes to setup Gazebo core experiment parameters.
|
64
|
+
|
65
|
+
Does not write generated changes to the run definition pickle
|
66
|
+
file.
|
67
|
+
"""
|
68
|
+
_logger.debug("Generating Gazebo experiment changes (all runs)")
|
69
|
+
|
70
|
+
# Start Gazebo/ROS in debug mode to make post-mortem analysis easier.
|
71
|
+
exp_def.element_add("./master/include",
|
72
|
+
"arg",
|
73
|
+
{
|
74
|
+
"name": "verbose",
|
75
|
+
"value": "true"
|
76
|
+
})
|
77
|
+
|
78
|
+
# Terminate Gazebo server whenever the launch script that invoked it
|
79
|
+
# exits.
|
80
|
+
exp_def.element_add("./master/include",
|
81
|
+
"arg",
|
82
|
+
{
|
83
|
+
"name": "server_required",
|
84
|
+
"value": "true"
|
85
|
+
})
|
86
|
+
|
87
|
+
# Don't record stuff
|
88
|
+
exp_def.element_remove("./master/include", "arg/[@name='headless']")
|
89
|
+
exp_def.element_remove("./master/include", "arg/[@name='recording']")
|
90
|
+
|
91
|
+
# Don't start paused
|
92
|
+
exp_def.element_remove("./master/include", "arg/[@name='paused']")
|
93
|
+
|
94
|
+
# Don't start gazebo under gdb
|
95
|
+
exp_def.element_remove("./master/include", "arg/[@name='debug']")
|
96
|
+
|
97
|
+
|
98
|
+
def _generate_all_exp_gazebo_vis(exp_def: definition.BaseExpDef) -> None:
|
99
|
+
"""
|
100
|
+
Generate XML changes to configure Gazebo visualizations.
|
101
|
+
|
102
|
+
Does not write generated changes to the simulation definition pickle
|
103
|
+
file.
|
104
|
+
"""
|
105
|
+
exp_def.element_remove_all("./master/include", "arg/[@name='gui']")
|
106
|
+
exp_def.element_add("./master/include",
|
107
|
+
"arg",
|
108
|
+
{
|
109
|
+
"name": "gui",
|
110
|
+
"value": "false"
|
111
|
+
})
|
112
|
+
|
113
|
+
|
114
|
+
def for_single_exp_run(*args, **kwargs) -> None:
|
115
|
+
"""Generate XML changes unique to each experimental run.
|
116
|
+
|
117
|
+
Wraps :py:func:`sierra.core.ros1.generators.for_single_exp_run`.
|
118
|
+
"""
|
119
|
+
return ros1.generators.for_single_exp_run(*args, **kwargs)
|
120
|
+
|
121
|
+
|
122
|
+
__all__ = [
|
123
|
+
'for_all_exp',
|
124
|
+
'for_single_exp_run'
|
125
|
+
]
|