Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic support for Modifiers #110

Merged
merged 39 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
673c8b5
current
fred-labs Jul 8, 2024
4aacacf
support rendering py tree
fred-labs Jul 8, 2024
85620df
doc
fred-labs Jul 8, 2024
9754071
doc
fred-labs Jul 8, 2024
abfca1a
doc
fred-labs Jul 8, 2024
dcd573a
Merge branch 'dot' into composite_modifier
fred-labs Jul 8, 2024
530868f
replace composite
fred-labs Jul 8, 2024
337759e
update py-trees
fred-labs Jul 8, 2024
ec649fc
remove submodule
fred-labs Jul 8, 2024
8e41e04
add dependency
fred-labs Jul 8, 2024
e1e5d9e
Update log.py
fred-labs Jul 8, 2024
7c00f4f
update tests
fred-labs Jul 8, 2024
5946df4
Merge branch 'py-trees-upgrade' into composite_modifier
fred-labs Jul 8, 2024
329ea2d
support multiple decorators
fred-labs Jul 9, 2024
93ff31c
add doc
fred-labs Jul 9, 2024
08c9778
support modifier in scenario
fred-labs Jul 9, 2024
658cbf3
Merge branch 'main' into composite_modifier
fred-labs Jul 9, 2024
4d49d1e
rework timeout handling
fred-labs Jul 9, 2024
78dcb55
add header
fred-labs Jul 9, 2024
32bcd7d
rework tests
fred-labs Jul 9, 2024
00193c1
rework tests
fred-labs Jul 9, 2024
24cf616
fix tests
fred-labs Jul 9, 2024
9ad16b1
Fix ci issues
fred-labs Jul 10, 2024
143ec66
Fix tests
fred-labs Jul 10, 2024
0c5af44
fix tests
fred-labs Jul 10, 2024
855ec93
Update tutorials.rst
fred-labs Jul 10, 2024
1aa0d03
Fix tests
fred-labs Jul 10, 2024
d914d62
Fix tests
fred-labs Jul 10, 2024
ea0c403
fixes after review
fred-labs Jul 10, 2024
fc07702
fix name for scenario-level decorator
fred-labs Jul 10, 2024
a05f575
fix bag_record
fred-labs Jul 10, 2024
b4f9be7
rosbag to artifact
fred-labs Jul 10, 2024
2da5289
CI test
fred-labs Jul 10, 2024
7dd2d4b
format
fmirus Jul 11, 2024
d3e76e2
pylint
fmirus Jul 11, 2024
3af7b4e
add pytrees to devcontainer debian requirements
fmirus Jul 15, 2024
e6c206f
Merge branch 'main' into composite_modifier
fred-labs Jul 16, 2024
36a05ba
Merge branch 'main' into composite_modifier
fred-labs Jul 17, 2024
2109000
cleanup
fred-labs Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 61 additions & 17 deletions docs/libraries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ For debugging purposes, log a string using the available log mechanism.
- String to log

``run_process()``
""""""""""""""""""""""""""
"""""""""""""""""

Run a process. Reports `running` while the process has not finished.

Expand Down Expand Up @@ -241,38 +241,82 @@ If ``wait_for_shutdown`` is ``false`` and the process is still running on scenar
- ``10s``
- (Only used if ``wait_for_shutdown`` is ``false``) time to wait between ``shutdown_signal`` and SIGKILL getting sent, if process is still running on scenario shutdown

OS
--

The library contains actions to interact with the operating system. Import it with ``import osc.os``. It is provided by the package :repo_link:`libs/scenario_execution_os`.
Modifiers
^^^^^^^^^

Actions
^^^^^^^
``inverter()``
""""""""""""""

``check_file_exists()``
"""""""""""""""""""""""
Modifier to invert the action result. A failing action will report ``success``, a succeeding action will report ``failure``.

Report success if a file exists.
``repeat()``
""""""""""""
Modifier to repeat a sub-tree. If any of the included children report ``failure``, the repetition stops and ``failure`` is reported.

.. list-table::
:widths: 15 15 5 65
:header-rows: 1
:class: tight-table

* - Parameter
- Type
- Default
- Description
* - ``file_name``
- ``string``
-
- File to check
* - ``count``
- ``int``
- ``-1``
- Repeat this many times (-1 to repeat indefinitely)

``retry()``
"""""""""""
Modifier to retry a sub-tree until it succeeds.

.. list-table::
:widths: 15 15 5 65
:header-rows: 1
:class: tight-table

* - Parameter
- Type
- Default
- Description
* - ``count``
- ``int``
-
- Maximum number of permitted failures

``timeout()``
"""""""""""""
Modifier to set a timeout for a sub-tree.

.. list-table::
:widths: 15 15 5 65
:header-rows: 1
:class: tight-table

``check_file_not_exists()``
"""""""""""""""""""""""""""
* - Parameter
- Type
- Default
- Description
* - ``count``
- ``int``
-
- Maximum number of permitted failures

Report success if a file does not exist.

OS
--

The library contains actions to interact with the operating system. Import it with ``import osc.os``. It is provided by the package :repo_link:`libs/scenario_execution_os`.

Actions
^^^^^^^

``check_file_exists()``
"""""""""""""""""""""""

Report success if a file exists.

.. list-table::
:widths: 15 15 5 65
Expand Down
36 changes: 30 additions & 6 deletions docs/openscenario2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,31 @@ The `standard library of
OSC2 <https://www.asam.net/static_downloads/public/asam-openscenario/2.0.0/domain-model/standard_library.html>`__
was adapted to be usable by the current parsing support of scenario execution.

In the following the supported features are described.

Mapping to py-trees
-------------------

.. list-table::
:widths: 15 25 60
:header-rows: 1
:class: tight-table

- * OpenScenario2
* py-trees
* Comment
- * ``action``
* ``Behaviour``
* Actions are derived from ``scenario_execution.actions.base_action.BaseAction`` which is derived from ``py_trees.behaviour.Behaviour``
- * ``event``
* blackboard entry and ``Behaviour``
* ``Behaviour`` is used to read and write blackboard variable
- * ``modifier``
* ``Decorator``
*
- * ``var``
* blackboard entry
* Variables are stored within the blackboard


.. role:: raw-html(raw)
:format: html
Expand Down Expand Up @@ -87,13 +111,13 @@ Composition Types

Composition types are ``struct``, ``actor``, ``action``, ``scenario``.

============== ==================== =========
============== ==================== ===========================
Element Type Support Notes
============== ==================== =========
============== ==================== ===========================
Event :raw-html:`&#9989;`
Field :raw-html:`&#9989;`
Constraint :raw-html:`&#9989;` partially
Method :raw-html:`&#10060;`
Method :raw-html:`&#9989;`
Coverage :raw-html:`&#10060;`
Modifier :raw-html:`&#10060;`
============== ==================== =========
Modifier :raw-html:`&#9989;` partially (only predefined)
============== ==================== ===========================
13 changes: 5 additions & 8 deletions docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,14 @@ screen. After the ``log`` action is invoked, the ``wait`` directive makes the sc
Scenario execution uses the predefined events ``end`` and ``fail`` to detect success or failure of a scenario. If no ``emit end`` or ``emit fail`` is defined, a success is assumed.

.. note::
It is good practice to define a timeout action in parallel to the expected actions within a scenario.
It is good practice to define a timeout modifier within a scenario or sub-tree or action.
fred-labs marked this conversation as resolved.
Show resolved Hide resolved

.. code-block::

scenario example:
do parallel:
serial:
...
serial:
wait elapsed(60s)
emit fail
timeout(60s)
do serial:
...

Use this code to see a launch of this tutorial:

Expand Down Expand Up @@ -442,4 +439,4 @@ Use this code to see a launch of this tutorial:
.. code-block:: bash

colcon build --packages-up-to example_external_method && source install/setup.bash \
&& ros2 run scenario_execution scenario_execution examples/example_external_method/scenarios/example_external_method.osc
&& ros2 run scenario_execution scenario_execution examples/example_external_method/scenarios/example_external_method.osc
18 changes: 2 additions & 16 deletions examples/example_multi_robot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,10 @@ source install/setup.bash
```
The Following example spawns 2 robots. The first robot is initialised with nav2 and moves in a straight line. Once it reaches a specific point a velocity command is sent to the second robot which will position itsel in front of the first one. The first robot then replans its path and moves around the second robot.

To actually run the scenario, run the following commands.
Note: due to an [issue](https://github.com/turtlebot/turtlebot4_simulator/issues/60) with the turtlebot simulation when running multiple robots, some launch commands need to run in separate terminals.
Launch the simulation and spawn the first robot by running the following command:
To actually run the scenario, run the following command.

```bash
ros2 launch tb4_sim_scenario sim_nav_scenario_launch.py scenario_execution:=False scenario:=foo yaw:=3.14
```

To spawn the second robot, run the following command in a new terminal:

```bash
ros2 launch tb4_sim_scenario ignition_robot_launch.py namespace:=turtlebot2 x:=-3.0 y:=1.5 yaw:=-1.57
```

To run the actual scenario, run the following command in a third terminal:

```bash
ros2 launch scenario_execution scenario_launch.py scenario:=examples/example_multi_robot/example_multi_robot.osc
ros2 launch tb4_sim_scenario sim_nav_scenario_launch.py scenario:=examples/example_multi_robot/example_multi_robot.osc
```

For a more detailed understanding of the code structure and scenario implementation please refer to the [tutorial documentation](https://intellabs.github.io/scenario_execution/tutorials.html).
Loading
Loading