Skip to content

Commit

Permalink
update from OpenSCENARIO 2.0 to OpenSCENARIO DSL V2.1.0 (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmirus authored Nov 14, 2024
1 parent 6a57579 commit acec266
Show file tree
Hide file tree
Showing 27 changed files with 116 additions and 1,123 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Super-Linter](https://github.com/IntelLabs/Scenario_Execution/actions/workflows/scan.yml/badge.svg)](https://github.com/marketplace/actions/super-linter)
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/IntelLabs/scenario_execution/badge)](https://scorecard.dev/viewer/?uri=github.com/IntelLabs/scenario_execution)

Scenario execution is a backend- and middleware-agnostic library written in Python based on the generic scenario description language [OpenSCENARIO 2](https://www.asam.net/static_downloads/public/asam-openscenario/2.0.0/welcome.html) and [pytrees](https://py-trees.readthedocs.io/en/devel/).
Scenario execution is a backend- and middleware-agnostic library written in Python based on the generic scenario description language [OpenSCENARIO DSL](https://www.asam.net/standards/detail/openscenario-dsl/) and [pytrees](https://py-trees.readthedocs.io/en/devel/).
It reads a scenario definition from a file and then executes it, reusing available checks and actions. It is easily extendable through a library mechanism.
This separation of the scenario definition from implementation massively reduces the manual efforts of scenario creation.

Expand Down
14 changes: 7 additions & 7 deletions docs/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Architecture

Overview of Scenario Execution

Scenario execution is built as a Python library on top of two open-source components: the generic scenario description language `OpenSCENARIO 2 <https://www.asam.net/index.php?eID=dumpFile&t=f&f=3460&token=14e7c7fab9c9b75118bb4939c725738fa0521fe9>`_ and `PyTrees <https://py-trees.readthedocs.io/en/devel/introduction.html>`_.
In general, the user defines a scenario in the OpenSCENARIO 2 language, scenario execution parses the scenario, translates it to a behavior tree, executes it and finally gathers the test results.
Scenario execution is built as a Python library on top of two open-source components: the generic scenario description language `OpenSCENARIO DSL <https://www.asam.net/index.php?eID=dumpFile&t=f&f=3460&token=14e7c7fab9c9b75118bb4939c725738fa0521fe9>`_ and `PyTrees <https://py-trees.readthedocs.io/en/devel/introduction.html>`_.
In general, the user defines a scenario in the OpenSCENARIO DSL language, scenario execution parses the scenario, translates it to a behavior tree, executes it and finally gathers the test results.


.. figure:: images/scenario_execution_arch.png
Expand All @@ -18,7 +18,7 @@ In general, the user defines a scenario in the OpenSCENARIO 2 language, scenario

Our implementation is highly modular separating the core components from simulation- and/or middleware-specific modules realized through a plugin-based approach.
In principle, any additional feature that is required by a specific scenario and that can be implemented in Python could be realized as additional library.
A library typically provides an OpenSCENARIO 2 file with additional definitions and may provide code implementing additional functionality such as conditions or actions.
A library typically provides an OpenSCENARIO DSL file with additional definitions and may provide code implementing additional functionality such as conditions or actions.

Currently, the following sub-packages and libraries are available:

Expand Down Expand Up @@ -63,11 +63,11 @@ The Internal Model Builder, implemented as a Model Listener does an initial chec
Modules
-------

- ``scenario_execution``: The base package for scenario execution. It provides the parsing of OpenSCENARIO 2 files and the conversion to py-trees. It's middleware agnostic and can therefore be used as a basis for more specific implementations (e.g. ROS). It also provides basic OpenSCENARIO 2 libraries and actions.
- ``scenario_execution_ros``: This package uses ``scenario_execution`` as a basis and implements a ROS2 version of scenario execution. It provides a OpenSCENARIO 2 library with basic ROS2-related actions like publishing on a topic or calling a service.
- ``scenario_execution``: The base package for scenario execution. It provides the parsing of OpenSCENARIO DSL files and the conversion to py-trees. It's middleware agnostic and can therefore be used as a basis for more specific implementations (e.g. ROS). It also provides basic OpenSCENARIO DSL libraries and actions.
- ``scenario_execution_ros``: This package uses ``scenario_execution`` as a basis and implements a ROS2 version of scenario execution. It provides a OpenSCENARIO DSL library with basic ROS2-related actions like publishing on a topic or calling a service.
- ``scenario_execution_control``: Provides code to control scenario execution (in ROS2) from another application such as RViz.
- ``scenario_execution_coverage``: Provides tools to generate concrete scenarios from abstract OpenSCENARIO 2 scenario definition and execute them.
- ``scenario_execution_gazebo``: Provides a `Gazebo <https://gazebosim.org/>`_-specific OpenSCENARIO 2 library with actions.
- ``scenario_execution_coverage``: Provides tools to generate concrete scenarios from abstract OpenSCENARIO DSL scenario definition and execute them.
- ``scenario_execution_gazebo``: Provides a `Gazebo <https://gazebosim.org/>`_-specific OpenSCENARIO DSL library with actions.
- ``scenario_execution_interfaces``: Provides ROS2 `interfaces <https://docs.ros.org/en/rolling/Concepts/Basic/About-Interfaces.html>`__, more specifically, messages and services, which are used to interface ROS2 with the ``scenario_execution_control`` package.
- ``scenario_execution_rviz``: Contains several `rviz <https://github.com/ros2/rviz>`__ plugins for visualizing and controlling scenarios when working with ROS2.
- ``simulation/gazebo_tf_publisher``: Publish ground truth transforms from simulation within TF.
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Scenario Execution
==================

Scenario Execution for Robotics is a backend- and middleware-agnostic library, that enables the robotics community to perform reproducible experiments at scale and allows a seamless transition from simulation to real-world experiments.
Scenario Execution is written in Python and builds upon the generic scenario description language `OpenScenario2 <https://www.asam.net/static_downloads/public/asam-openscenario/2.0.0/welcome.html>`__ and `pytrees <https://py-trees.readthedocs.io/en/devel/>`__.
Scenario Execution is written in Python and builds upon the generic scenario description language `OpenSCENARIO DSL <https://www.asam.net/standards/detail/openscenario-dsl/>`__ and `pytrees <https://py-trees.readthedocs.io/en/devel/>`__.

Scenario Execution reads a scenario definition from a file, translates it to a py-trees behavior tree and then executes it. This separation of the scenario definition from the implementation massively reduces the manual efforts of (robotics) scenario creation.
Although Scenario Execution can be used as a pure Python library, it is mainly targeted to be used with the `Robot Operating System (ROS2) <https://www.ros.org/>`__. The backend-agnostic implementation allows Scenario Execution to be used with both, robotics simulators such as `Gazebo <https://gazebosim.org/>`__ and physical robots, with minimal adaptations necessary in the scenario description file. 
Expand Down Expand Up @@ -37,5 +37,5 @@ If you use Scenario Execution for Robotics in your scientific work, please cite
architecture
libraries
development
openscenario2
openscenarioDSL
how_to_cite
2 changes: 1 addition & 1 deletion docs/libraries.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Libraries
=========

Beside ``osc.standard`` provided by OpenSCENARIO 2 (which we divide into ``osc.standard`` and ``osc.standard_base``), multiple libraries are provided with scenario execution.
Beside ``osc.standard`` and ``osc.types`` provided by OpenSCENARIO DSL, multiple libraries are provided with scenario execution.

.. list-table::
:widths: 40 60
Expand Down
13 changes: 6 additions & 7 deletions docs/openscenario2.rst → docs/openscenarioDSL.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
OpenSCENARIO 2
==============
OpenSCENARIO DSL
================

General
-------

This tool supports a subset of the `OpenSCENARIO
2 <https://www.asam.net/project-detail/asam-openscenario-v20-1/>`__ standard.
This tool supports a subset of the `OpenSCENARIO DSL <https://www.asam.net/standards/detail/openscenario-dsl/>`__ standard.

The official documentation is available
`here <https://www.asam.net/static_downloads/public/asam-openscenario/2.0.0/welcome.html>`__.
`here <https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/index.html>`__.

The `standard library of
OSC2 <https://www.asam.net/static_downloads/public/asam-openscenario/2.0.0/domain-model/standard_library.html>`__
OSC2 <https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/_attachments/ASAM_OpenSCENARIO_DSL_v2.1.0_Domain_model_library.zip>`__
was adapted to be usable by the current parsing support of scenario execution.


Expand Down Expand Up @@ -46,7 +45,7 @@ Mapping to py-trees
Supported features
------------------

In the following the OpenSCENARIO 2 keywords are listed with their current support status.
In the following the OpenSCENARIO DSL keywords are listed with their current support status.


======================= ==================== =============================
Expand Down
16 changes: 8 additions & 8 deletions docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Code for all tutorials is available in :repo_link:`examples`.
Define and Execute Scenario
---------------------------

To create a scenario in OpenSCENARIO 2 syntax, first create a file
To create a scenario in OpenSCENARIO DSL syntax, first create a file
with the extension ``.osc``. Input the following code in the file.

.. code-block::
# import the libraries with import expression
import osc.standard.base
import osc.types
import osc.helpers
# declare the scenario by the syntax: "scenario scenario_name:"
Expand All @@ -25,17 +25,17 @@ with the extension ``.osc``. Input the following code in the file.
wait elapsed(3s) # wait three seconds
log("Good Bye!") # log another message
The first two lines ``import osc.standard.base`` and ``import osc.helpers`` will import the named libraries that provide required definitions. In this example ``helpers`` library provides the ``log`` action and ``standard.base`` provides the definition of the `s` unit to specify seconds.
The first two lines ``import osc.types`` and ``import osc.helpers`` will import the named libraries that provide required definitions. In this example ``helpers`` library provides the ``log`` action and ``types`` provides the definition of the `s` unit to specify seconds.

.. note::
Comments in OpenSCENARIO 2 always start with ``#``.
Comments in OpenSCENARIO DSL always start with ``#``.

Then, a scenario with the name ``hello_world`` get declared. The following colon states that all following and indented lines
are part of it. The single top-level action of the scenario is defined in the ``do`` directive.
The term ``serial`` states that the included actions will be executed in sequence.

.. note::
OpenSCENARIO 2 supports the following compositions:
OpenSCENARIO DSL supports the following compositions:

* ``parallel``: execute actions in parallel, continue afterwards
* ``serial``: execute actions, one after the other
Expand Down Expand Up @@ -70,11 +70,11 @@ Create Scenario Library
-----------------------

To add new features to scenario execution, extensions libraries can be created. An extension library typically provides one or more
OpenSCENARIO 2 definition files and might additionally provide action implementations.
OpenSCENARIO DSL definition files and might additionally provide action implementations.

To show how to create such a library for scenario execution, we will add a ``custom_action`` action as an example.

First, we need to define the ``custom_action`` in a OpenSCENARIO 2 file.
First, we need to define the ``custom_action`` in a OpenSCENARIO DSL file.

.. code-block::
Expand Down Expand Up @@ -417,7 +417,7 @@ It is possible to call external python methods and use their return value within

.. code-block::
import osc.standard.base
import osc.types
import osc.helpers
struct lib:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types
import osc.helpers

struct lib:
Expand All @@ -7,4 +7,4 @@ struct lib:
scenario example_external_method:

do serial:
log(lib.factorial(4))
log(lib.factorial(4))
2 changes: 1 addition & 1 deletion examples/example_scenario/hello_world.osc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types
import osc.helpers

scenario hello_world:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types

actor floorplan_generator:
result: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types
import osc.robotics

action actor_exists:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types

enum kubernetes_element_type: [
pod,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types
import osc.kubernetes
import osc.helpers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types
import osc.kubernetes
import osc.helpers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types
import osc.robotics

enum move_group_type: [
Expand Down Expand Up @@ -46,4 +46,4 @@ action arm.move_to_pose:
max_velocity_scaling_factor: float = 0.1 # Scaling factors for optionally reducing the maximum joint velocities
namespace_override: string = '' # if set, it's used as namespace (instead of the associated actor's name)
action_topic: string = 'move_action' # Name of action
success_on_acceptance: bool = false # succeed on goal acceptance
success_on_acceptance: bool = false # succeed on goal acceptance
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types
import osc.robotics

action differential_drive_robot.init_nav2:
Expand All @@ -21,4 +21,4 @@ action differential_drive_robot.nav_to_pose:
goal_pose: pose_3d # goal pose to navigate to
namespace_override: string = '' # if set, it's used as namespace (instead of the associated actor's name)
action_topic: string = 'navigate_to_pose' # Name of action
success_on_acceptance: bool = false # succeed on goal acceptance
success_on_acceptance: bool = false # succeed on goal acceptance
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types
import osc.robotics

actor simulation_pybullet
Expand All @@ -20,4 +20,4 @@ action actor_pybullet.set_joint_motor_control:

action actor_pybullet.distance_traveled:
# Wait until a defined distance was traveled, based on simulation ground truth
distance: length # traveled distance at which the action succeeds.
distance: length # traveled distance at which the action succeeds.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types

action capture_screen:
# Capture the screen content within a video
Expand Down
4 changes: 2 additions & 2 deletions scenario_execution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ The `scenario_execution` package is the core package of Scenario Execution for R

Furthermore, it provides the following scenario execution libraries:

- `standard.osc`: The OpenSCENARIO 2 standard library. It is slightly modified to be in sync with the feature set of scenario execution and imports `standard_base.osc`.
- `standard_base.osc`: The base parts of the OpenSCENARIO 2 standard library such as units and basic structs. For convenience, numerical struct members are initialized with 0.
- `standard.osc`: The OpenSCENARIO DSL standard library. It is slightly modified to be in sync with the feature set of scenario execution and imports `standard_base.osc`.
- `standard_base.osc`: The base parts of the OpenSCENARIO DSL standard library such as units and basic structs. For convenience, numerical struct members are initialized with 0.
- `robotics.osc`: robotic-specific specifications.
- `helper.osc`: helper actions such as logging or running external processes.

4 changes: 2 additions & 2 deletions scenario_execution/scenario_execution/get_osc_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ def get_standard_library():
return 'scenario_execution', 'standard.osc'


def get_standard_base_library():
return 'scenario_execution', 'standard_base.osc'
def get_types_library():
return 'scenario_execution', 'types.osc'
2 changes: 1 addition & 1 deletion scenario_execution/scenario_execution/lib_osc/helpers.osc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import osc.standard.base
import osc.types

enum signal: [
sighup = 1,
Expand Down
2 changes: 1 addition & 1 deletion scenario_execution/scenario_execution/lib_osc/robotics.osc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import osc.standard.base
import osc.types

actor robot inherits osc_actor
Loading

0 comments on commit acec266

Please sign in to comment.