scenario-execution 1.0.0__tar.gz
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.
- scenario-execution-1.0.0/MANIFEST.in +1 -0
- scenario-execution-1.0.0/PKG-INFO +34 -0
- scenario-execution-1.0.0/README.md +11 -0
- scenario-execution-1.0.0/package.xml +21 -0
- scenario-execution-1.0.0/pyproject.toml +52 -0
- scenario-execution-1.0.0/resource/scenario_execution_base +0 -0
- scenario-execution-1.0.0/scenario_execution.egg-info/PKG-INFO +34 -0
- scenario-execution-1.0.0/scenario_execution.egg-info/SOURCES.txt +61 -0
- scenario-execution-1.0.0/scenario_execution.egg-info/dependency_links.txt +1 -0
- scenario-execution-1.0.0/scenario_execution.egg-info/entry_points.txt +12 -0
- scenario-execution-1.0.0/scenario_execution.egg-info/requires.txt +7 -0
- scenario-execution-1.0.0/scenario_execution.egg-info/top_level.txt +4 -0
- scenario-execution-1.0.0/scenario_execution.egg-info/zip-safe +1 -0
- scenario-execution-1.0.0/scenario_execution_base/__init__.py +30 -0
- scenario-execution-1.0.0/scenario_execution_base/actions/__init__.py +15 -0
- scenario-execution-1.0.0/scenario_execution_base/actions/log.py +54 -0
- scenario-execution-1.0.0/scenario_execution_base/actions/run_process.py +135 -0
- scenario-execution-1.0.0/scenario_execution_base/get_osc_library.py +30 -0
- scenario-execution-1.0.0/scenario_execution_base/lib_osc/helpers.osc +8 -0
- scenario-execution-1.0.0/scenario_execution_base/lib_osc/robotics.osc +3 -0
- scenario-execution-1.0.0/scenario_execution_base/lib_osc/standard.osc +990 -0
- scenario-execution-1.0.0/scenario_execution_base/lib_osc/standard_base.osc +251 -0
- scenario-execution-1.0.0/scenario_execution_base/model/__init__.py +15 -0
- scenario-execution-1.0.0/scenario_execution_base/model/error.py +38 -0
- scenario-execution-1.0.0/scenario_execution_base/model/model_base_visitor.py +266 -0
- scenario-execution-1.0.0/scenario_execution_base/model/model_builder.py +1990 -0
- scenario-execution-1.0.0/scenario_execution_base/model/model_file_loader.py +52 -0
- scenario-execution-1.0.0/scenario_execution_base/model/model_resolver.py +284 -0
- scenario-execution-1.0.0/scenario_execution_base/model/model_to_py_tree.py +279 -0
- scenario-execution-1.0.0/scenario_execution_base/model/osc2_parser.py +138 -0
- scenario-execution-1.0.0/scenario_execution_base/model/types.py +2112 -0
- scenario-execution-1.0.0/scenario_execution_base/osc2_parsing/OpenSCENARIO2Lexer.py +757 -0
- scenario-execution-1.0.0/scenario_execution_base/osc2_parsing/OpenSCENARIO2Listener.py +1251 -0
- scenario-execution-1.0.0/scenario_execution_base/osc2_parsing/OpenSCENARIO2Parser.py +10461 -0
- scenario-execution-1.0.0/scenario_execution_base/osc2_parsing/OpenSCENARIO2Visitor.py +642 -0
- scenario-execution-1.0.0/scenario_execution_base/osc2_parsing/__init__.py +15 -0
- scenario-execution-1.0.0/scenario_execution_base/scenario_execution.py +368 -0
- scenario-execution-1.0.0/scenario_execution_base/utils/__init__.py +15 -0
- scenario-execution-1.0.0/scenario_execution_base/utils/logging.py +109 -0
- scenario-execution-1.0.0/setup.cfg +10 -0
- scenario-execution-1.0.0/setup.py +57 -0
- scenario-execution-1.0.0/test/test_expression.py +153 -0
- scenario-execution-1.0.0/test/test_model_ser_deser.py +80 -0
- scenario-execution-1.0.0/test/test_osc2_parser_action.py +63 -0
- scenario-execution-1.0.0/test/test_osc2_parser_actor.py +73 -0
- scenario-execution-1.0.0/test/test_osc2_parser_behavior_invocation.py +416 -0
- scenario-execution-1.0.0/test/test_osc2_parser_enum.py +152 -0
- scenario-execution-1.0.0/test/test_osc2_parser_event.py +64 -0
- scenario-execution-1.0.0/test/test_osc2_parser_keep.py +49 -0
- scenario-execution-1.0.0/test/test_osc2_parser_list.py +143 -0
- scenario-execution-1.0.0/test/test_osc2_parser_not_supported.py +274 -0
- scenario-execution-1.0.0/test/test_osc2_parser_parameter.py +522 -0
- scenario-execution-1.0.0/test/test_osc2_parser_physical_type.py +65 -0
- scenario-execution-1.0.0/test/test_osc2_parser_si.py +81 -0
- scenario-execution-1.0.0/test/test_osc2_parser_struct.py +178 -0
- scenario-execution-1.0.0/test/test_osc2_parser_wait.py +93 -0
- scenario-execution-1.0.0/test/test_osc2_standard_osc.py +49 -0
- scenario-execution-1.0.0/test/test_run_process.py +113 -0
- scenario-execution-1.0.0/test/test_scenario_events.py +92 -0
- scenario-execution-1.0.0/test/test_scenario_execution.py +68 -0
- scenario-execution-1.0.0/test/test_scenario_oneof.py +63 -0
- scenario-execution-1.0.0/test/test_scenario_parallel.py +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include scenario_execution_base/lib_osc/*.osc
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: scenario-execution
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Robotics Scenario Execution
|
|
5
|
+
Author-email: Intel Labs <scenario-execution@intel.com>
|
|
6
|
+
Maintainer: Intel Labs
|
|
7
|
+
Maintainer-email: Intel Labs <scenario-execution@intel.com>
|
|
8
|
+
License: Apache License 2.0
|
|
9
|
+
Project-URL: Homepage, https://github.com/IntelLabs/scenario_execution
|
|
10
|
+
Project-URL: Documentation, https://intellabs.github.io/scenario_execution/
|
|
11
|
+
Project-URL: Issues, https://github.com/IntelLabs/scenario_execution/issues
|
|
12
|
+
Keywords: robotics,scenarios,experiments,testing
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: setuptools
|
|
17
|
+
Requires-Dist: antlr4-python3-runtime==4.7.2
|
|
18
|
+
Requires-Dist: transforms3d==0.3.1
|
|
19
|
+
Requires-Dist: pexpect==4.9.0
|
|
20
|
+
Requires-Dist: defusedxml==0.7.1
|
|
21
|
+
Requires-Dist: pyyaml
|
|
22
|
+
Requires-Dist: py-trees==2.1.6
|
|
23
|
+
|
|
24
|
+
# Scenario Execution Base Package
|
|
25
|
+
|
|
26
|
+
The `scenario_execution_base` package is the base package for scenario execution. It provides functionalities like parsing, py-trees creation and execution.
|
|
27
|
+
|
|
28
|
+
It provides the following scenario execution libraries:
|
|
29
|
+
|
|
30
|
+
- `standard.osc`: The OpenSCENARIO 2 standard library. It is slightly modified to be in sync with the feature set of scenario execution. For convenience, numerical struct members are initialized with 0.
|
|
31
|
+
- `robotics.osc`: robotic-specific specifications
|
|
32
|
+
- `helper.osc`: helper actions
|
|
33
|
+
- `networking.osc`: actions related to networking
|
|
34
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Scenario Execution Base Package
|
|
2
|
+
|
|
3
|
+
The `scenario_execution_base` package is the base package for scenario execution. It provides functionalities like parsing, py-trees creation and execution.
|
|
4
|
+
|
|
5
|
+
It provides the following scenario execution libraries:
|
|
6
|
+
|
|
7
|
+
- `standard.osc`: The OpenSCENARIO 2 standard library. It is slightly modified to be in sync with the feature set of scenario execution. For convenience, numerical struct members are initialized with 0.
|
|
8
|
+
- `robotics.osc`: robotic-specific specifications
|
|
9
|
+
- `helper.osc`: helper actions
|
|
10
|
+
- `networking.osc`: actions related to networking
|
|
11
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
|
3
|
+
<package format="3">
|
|
4
|
+
<name>scenario_execution_base</name>
|
|
5
|
+
<version>1.0.0</version>
|
|
6
|
+
<description>Robotics Scenario Execution</description>
|
|
7
|
+
<author email="scenario-execution@intel.com">Intel Labs</author>
|
|
8
|
+
<maintainer email="scenario-execution@intel.com">Intel Labs</maintainer>
|
|
9
|
+
<license file="../LICENSE">Apache-2.0</license>
|
|
10
|
+
|
|
11
|
+
<exec_depend>py_trees</exec_depend>
|
|
12
|
+
|
|
13
|
+
<test_depend>ament_copyright</test_depend>
|
|
14
|
+
<test_depend>ament_flake8</test_depend>
|
|
15
|
+
<test_depend>ament_pep257</test_depend>
|
|
16
|
+
<test_depend>python3-pytest</test_depend>
|
|
17
|
+
|
|
18
|
+
<export>
|
|
19
|
+
<build_type>ament_python</build_type>
|
|
20
|
+
</export>
|
|
21
|
+
</package>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "scenario-execution"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
dynamic = ["license"]
|
|
9
|
+
description = "Robotics Scenario Execution"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
keywords = ["robotics", "scenarios", "experiments", "testing"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Intel Labs", email = "scenario-execution@intel.com"}
|
|
15
|
+
]
|
|
16
|
+
maintainers = [
|
|
17
|
+
{ name = "Intel Labs", email = "scenario-execution@intel.com" },
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"setuptools",
|
|
21
|
+
"antlr4-python3-runtime==4.7.2",
|
|
22
|
+
"transforms3d==0.3.1",
|
|
23
|
+
"pexpect==4.9.0",
|
|
24
|
+
"defusedxml==0.7.1",
|
|
25
|
+
"pyyaml",
|
|
26
|
+
"py-trees==2.1.6",
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
scenario_execution = "scenario_execution_base.scenario_execution:main"
|
|
34
|
+
|
|
35
|
+
[project.entry-points."scenario_execution.actions"]
|
|
36
|
+
log = "scenario_execution_base.actions.log:Log"
|
|
37
|
+
run_process = "scenario_execution_base.actions.run_process:RunProcess"
|
|
38
|
+
|
|
39
|
+
[project.entry-points."scenario_execution.osc_libraries"]
|
|
40
|
+
helpers = "scenario_execution_base.get_osc_library:get_helpers_library"
|
|
41
|
+
robotics = "scenario_execution_base.get_osc_library:get_robotics_library"
|
|
42
|
+
standard = "scenario_execution_base.get_osc_library:get_standard_library"
|
|
43
|
+
"standard.base" = "scenario_execution_base.get_osc_library:get_standard_base_library"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.packages]
|
|
47
|
+
find = {} # Scanning implicit namespaces is active by default
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://github.com/IntelLabs/scenario_execution"
|
|
51
|
+
Documentation = "https://intellabs.github.io/scenario_execution/"
|
|
52
|
+
Issues = "https://github.com/IntelLabs/scenario_execution/issues"
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: scenario-execution
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Robotics Scenario Execution
|
|
5
|
+
Author-email: Intel Labs <scenario-execution@intel.com>
|
|
6
|
+
Maintainer: Intel Labs
|
|
7
|
+
Maintainer-email: Intel Labs <scenario-execution@intel.com>
|
|
8
|
+
License: Apache License 2.0
|
|
9
|
+
Project-URL: Homepage, https://github.com/IntelLabs/scenario_execution
|
|
10
|
+
Project-URL: Documentation, https://intellabs.github.io/scenario_execution/
|
|
11
|
+
Project-URL: Issues, https://github.com/IntelLabs/scenario_execution/issues
|
|
12
|
+
Keywords: robotics,scenarios,experiments,testing
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: setuptools
|
|
17
|
+
Requires-Dist: antlr4-python3-runtime==4.7.2
|
|
18
|
+
Requires-Dist: transforms3d==0.3.1
|
|
19
|
+
Requires-Dist: pexpect==4.9.0
|
|
20
|
+
Requires-Dist: defusedxml==0.7.1
|
|
21
|
+
Requires-Dist: pyyaml
|
|
22
|
+
Requires-Dist: py-trees==2.1.6
|
|
23
|
+
|
|
24
|
+
# Scenario Execution Base Package
|
|
25
|
+
|
|
26
|
+
The `scenario_execution_base` package is the base package for scenario execution. It provides functionalities like parsing, py-trees creation and execution.
|
|
27
|
+
|
|
28
|
+
It provides the following scenario execution libraries:
|
|
29
|
+
|
|
30
|
+
- `standard.osc`: The OpenSCENARIO 2 standard library. It is slightly modified to be in sync with the feature set of scenario execution. For convenience, numerical struct members are initialized with 0.
|
|
31
|
+
- `robotics.osc`: robotic-specific specifications
|
|
32
|
+
- `helper.osc`: helper actions
|
|
33
|
+
- `networking.osc`: actions related to networking
|
|
34
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
package.xml
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.cfg
|
|
6
|
+
setup.py
|
|
7
|
+
resource/scenario_execution_base
|
|
8
|
+
scenario_execution.egg-info/PKG-INFO
|
|
9
|
+
scenario_execution.egg-info/SOURCES.txt
|
|
10
|
+
scenario_execution.egg-info/dependency_links.txt
|
|
11
|
+
scenario_execution.egg-info/entry_points.txt
|
|
12
|
+
scenario_execution.egg-info/requires.txt
|
|
13
|
+
scenario_execution.egg-info/top_level.txt
|
|
14
|
+
scenario_execution.egg-info/zip-safe
|
|
15
|
+
scenario_execution_base/__init__.py
|
|
16
|
+
scenario_execution_base/get_osc_library.py
|
|
17
|
+
scenario_execution_base/scenario_execution.py
|
|
18
|
+
scenario_execution_base/actions/__init__.py
|
|
19
|
+
scenario_execution_base/actions/log.py
|
|
20
|
+
scenario_execution_base/actions/run_process.py
|
|
21
|
+
scenario_execution_base/lib_osc/helpers.osc
|
|
22
|
+
scenario_execution_base/lib_osc/robotics.osc
|
|
23
|
+
scenario_execution_base/lib_osc/standard.osc
|
|
24
|
+
scenario_execution_base/lib_osc/standard_base.osc
|
|
25
|
+
scenario_execution_base/model/__init__.py
|
|
26
|
+
scenario_execution_base/model/error.py
|
|
27
|
+
scenario_execution_base/model/model_base_visitor.py
|
|
28
|
+
scenario_execution_base/model/model_builder.py
|
|
29
|
+
scenario_execution_base/model/model_file_loader.py
|
|
30
|
+
scenario_execution_base/model/model_resolver.py
|
|
31
|
+
scenario_execution_base/model/model_to_py_tree.py
|
|
32
|
+
scenario_execution_base/model/osc2_parser.py
|
|
33
|
+
scenario_execution_base/model/types.py
|
|
34
|
+
scenario_execution_base/osc2_parsing/OpenSCENARIO2Lexer.py
|
|
35
|
+
scenario_execution_base/osc2_parsing/OpenSCENARIO2Listener.py
|
|
36
|
+
scenario_execution_base/osc2_parsing/OpenSCENARIO2Parser.py
|
|
37
|
+
scenario_execution_base/osc2_parsing/OpenSCENARIO2Visitor.py
|
|
38
|
+
scenario_execution_base/osc2_parsing/__init__.py
|
|
39
|
+
scenario_execution_base/utils/__init__.py
|
|
40
|
+
scenario_execution_base/utils/logging.py
|
|
41
|
+
test/test_expression.py
|
|
42
|
+
test/test_model_ser_deser.py
|
|
43
|
+
test/test_osc2_parser_action.py
|
|
44
|
+
test/test_osc2_parser_actor.py
|
|
45
|
+
test/test_osc2_parser_behavior_invocation.py
|
|
46
|
+
test/test_osc2_parser_enum.py
|
|
47
|
+
test/test_osc2_parser_event.py
|
|
48
|
+
test/test_osc2_parser_keep.py
|
|
49
|
+
test/test_osc2_parser_list.py
|
|
50
|
+
test/test_osc2_parser_not_supported.py
|
|
51
|
+
test/test_osc2_parser_parameter.py
|
|
52
|
+
test/test_osc2_parser_physical_type.py
|
|
53
|
+
test/test_osc2_parser_si.py
|
|
54
|
+
test/test_osc2_parser_struct.py
|
|
55
|
+
test/test_osc2_parser_wait.py
|
|
56
|
+
test/test_osc2_standard_osc.py
|
|
57
|
+
test/test_run_process.py
|
|
58
|
+
test/test_scenario_events.py
|
|
59
|
+
test/test_scenario_execution.py
|
|
60
|
+
test/test_scenario_oneof.py
|
|
61
|
+
test/test_scenario_parallel.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
scenario_execution = scenario_execution_base.scenario_execution:main
|
|
3
|
+
|
|
4
|
+
[scenario_execution.actions]
|
|
5
|
+
log = scenario_execution_base.actions.log:Log
|
|
6
|
+
run_process = scenario_execution_base.actions.run_process:RunProcess
|
|
7
|
+
|
|
8
|
+
[scenario_execution.osc_libraries]
|
|
9
|
+
helpers = scenario_execution_base.get_osc_library:get_helpers_library
|
|
10
|
+
robotics = scenario_execution_base.get_osc_library:get_robotics_library
|
|
11
|
+
standard = scenario_execution_base.get_osc_library:get_standard_library
|
|
12
|
+
standard.base = scenario_execution_base.get_osc_library:get_standard_base_library
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright (C) 2024 Intel Corporation
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing,
|
|
10
|
+
# software distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions
|
|
13
|
+
# and limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
from . import actions
|
|
18
|
+
from . import utils
|
|
19
|
+
from . import model
|
|
20
|
+
from scenario_execution_base.scenario_execution import ScenarioExecution
|
|
21
|
+
from scenario_execution_base.utils.logging import BaseLogger, Logger
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
'actions',
|
|
25
|
+
'utils',
|
|
26
|
+
'model',
|
|
27
|
+
'BaseLogger',
|
|
28
|
+
"Logger",
|
|
29
|
+
'ScenarioExecution'
|
|
30
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Copyright (C) 2024 Intel Corporation
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing,
|
|
10
|
+
# software distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions
|
|
13
|
+
# and limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Copyright (C) 2024 Intel Corporation
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing,
|
|
10
|
+
# software distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions
|
|
13
|
+
# and limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
import py_trees
|
|
18
|
+
from py_trees.common import Status
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Log(py_trees.behaviour.Behaviour):
|
|
22
|
+
"""
|
|
23
|
+
Class for logging
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
msg [str]: message to log
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(self, name, msg: str):
|
|
30
|
+
super().__init__(name)
|
|
31
|
+
self.msg = msg
|
|
32
|
+
self.published = False
|
|
33
|
+
self.logger = None
|
|
34
|
+
|
|
35
|
+
def setup(self, **kwargs) -> None:
|
|
36
|
+
"""
|
|
37
|
+
setup before ticking
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
kwargs: arguments passed from py_trees.behaviour.Behaviour
|
|
41
|
+
"""
|
|
42
|
+
self.logger = kwargs['logger']
|
|
43
|
+
|
|
44
|
+
def update(self) -> py_trees.common.Status:
|
|
45
|
+
"""
|
|
46
|
+
execute the action
|
|
47
|
+
|
|
48
|
+
return:
|
|
49
|
+
py_trees.common.Status.SUCCESS if the action is executed
|
|
50
|
+
"""
|
|
51
|
+
if not self.published:
|
|
52
|
+
self.published = True
|
|
53
|
+
self.logger.info(self.msg)
|
|
54
|
+
return Status.SUCCESS
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Copyright (C) 2024 Intel Corporation
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing,
|
|
10
|
+
# software distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions
|
|
13
|
+
# and limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
import py_trees # pylint: disable=import-error
|
|
18
|
+
import subprocess # nosec B404
|
|
19
|
+
from threading import Thread
|
|
20
|
+
from collections import deque
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class RunProcess(py_trees.behaviour.Behaviour):
|
|
24
|
+
"""
|
|
25
|
+
Class to execute an process. It finishes when the process finishes
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
command[str]: command to execute
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, name, command=None):
|
|
32
|
+
super().__init__(name)
|
|
33
|
+
self.command = command.split(" ") if isinstance(command, str) else command
|
|
34
|
+
self.executed = False
|
|
35
|
+
self.process = None
|
|
36
|
+
self.log_stdout_thread = None
|
|
37
|
+
self.log_stderr_thread = None
|
|
38
|
+
self.output = deque()
|
|
39
|
+
|
|
40
|
+
def update(self) -> py_trees.common.Status:
|
|
41
|
+
"""
|
|
42
|
+
Start/monitor process
|
|
43
|
+
|
|
44
|
+
return:
|
|
45
|
+
py_trees.common.Status
|
|
46
|
+
"""
|
|
47
|
+
if not self.executed:
|
|
48
|
+
self.executed = True
|
|
49
|
+
try:
|
|
50
|
+
self.process = subprocess.Popen(
|
|
51
|
+
self.command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
52
|
+
except Exception as e: # pylint: disable=broad-except
|
|
53
|
+
self.logger.error(str(e))
|
|
54
|
+
return py_trees.common.Status.FAILURE
|
|
55
|
+
|
|
56
|
+
self.feedback_message = f"Executing '{self.command}'" # pylint: disable= attribute-defined-outside-init
|
|
57
|
+
self.on_executed()
|
|
58
|
+
|
|
59
|
+
def log_output(out, log_fct, buffer):
|
|
60
|
+
try:
|
|
61
|
+
for line in iter(out.readline, b''):
|
|
62
|
+
msg = line.decode().strip()
|
|
63
|
+
if log_fct:
|
|
64
|
+
log_fct(msg)
|
|
65
|
+
buffer.append(msg)
|
|
66
|
+
out.close()
|
|
67
|
+
except ValueError:
|
|
68
|
+
pass
|
|
69
|
+
|
|
70
|
+
self.log_stdout_thread = Thread(target=log_output, args=(
|
|
71
|
+
self.process.stdout, self.get_logger_stdout(), self.output))
|
|
72
|
+
self.log_stdout_thread.daemon = True # die with the program
|
|
73
|
+
self.log_stdout_thread.start()
|
|
74
|
+
|
|
75
|
+
self.log_stderr_thread = Thread(target=log_output, args=(
|
|
76
|
+
self.process.stderr, self.get_logger_stderr(), self.output))
|
|
77
|
+
self.log_stderr_thread.daemon = True # die with the program
|
|
78
|
+
self.log_stderr_thread.start()
|
|
79
|
+
|
|
80
|
+
if self.process is None:
|
|
81
|
+
return py_trees.common.Status.FAILURE
|
|
82
|
+
|
|
83
|
+
ret = self.process.poll()
|
|
84
|
+
|
|
85
|
+
if ret is None:
|
|
86
|
+
return self.check_running_process()
|
|
87
|
+
else:
|
|
88
|
+
return self.on_process_finished(ret)
|
|
89
|
+
|
|
90
|
+
def get_logger_stdout(self):
|
|
91
|
+
"""
|
|
92
|
+
get logger for stderr messages
|
|
93
|
+
"""
|
|
94
|
+
return self.logger.info
|
|
95
|
+
|
|
96
|
+
def get_logger_stderr(self):
|
|
97
|
+
"""
|
|
98
|
+
get logger for stderr messages
|
|
99
|
+
"""
|
|
100
|
+
return self.logger.error
|
|
101
|
+
|
|
102
|
+
def check_running_process(self):
|
|
103
|
+
"""
|
|
104
|
+
hook to check running process
|
|
105
|
+
|
|
106
|
+
return:
|
|
107
|
+
py_trees.common.Status
|
|
108
|
+
"""
|
|
109
|
+
return py_trees.common.Status.RUNNING
|
|
110
|
+
|
|
111
|
+
def on_process_finished(self, ret):
|
|
112
|
+
"""
|
|
113
|
+
hook to check finished process
|
|
114
|
+
|
|
115
|
+
return:
|
|
116
|
+
py_trees.common.Status
|
|
117
|
+
"""
|
|
118
|
+
if ret == 0:
|
|
119
|
+
self.feedback_message = f"Successfully executed '{self.command}'" # pylint: disable= attribute-defined-outside-init
|
|
120
|
+
return py_trees.common.Status.SUCCESS
|
|
121
|
+
else:
|
|
122
|
+
self.feedback_message = f"Execution of '{self.command}' failed with {ret}" # pylint: disable= attribute-defined-outside-init
|
|
123
|
+
return py_trees.common.Status.FAILURE
|
|
124
|
+
|
|
125
|
+
def on_executed(self):
|
|
126
|
+
"""
|
|
127
|
+
hook for subclassed
|
|
128
|
+
"""
|
|
129
|
+
pass
|
|
130
|
+
|
|
131
|
+
def set_command(self, command):
|
|
132
|
+
self.command = command
|
|
133
|
+
|
|
134
|
+
def get_command(self):
|
|
135
|
+
return self.command
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright (C) 2024 Intel Corporation
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing,
|
|
10
|
+
# software distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions
|
|
13
|
+
# and limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
def get_robotics_library():
|
|
18
|
+
return 'scenario_execution_base', 'robotics.osc'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_helpers_library():
|
|
22
|
+
return 'scenario_execution_base', 'helpers.osc'
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_standard_library():
|
|
26
|
+
return 'scenario_execution_base', 'standard.osc'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_standard_base_library():
|
|
30
|
+
return 'scenario_execution_base', 'standard_base.osc'
|