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 library scenario_execution_os #99

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
colcon test --packages-select \
scenario_execution \
scenario_execution_gazebo \
scenario_execution_os \
scenario_coverage \
--event-handlers console_direct+ \
--return-code-on-test-failure \
Expand Down Expand Up @@ -399,6 +400,7 @@ jobs:
downloaded-artifacts/test-scenario-execution/scenario_execution/TEST.xml
downloaded-artifacts/test-scenario-execution-ros/scenario_execution_ros/TEST.xml
downloaded-artifacts/test-scenario-execution/scenario_coverage/TEST.xml
downloaded-artifacts/test-scenario-execution/libs/scenario_execution_os/TEST.xml
downloaded-artifacts/test-example-scenario-result/test.xml
downloaded-artifacts/test-example-library-result/test.xml
downloaded-artifacts/test-example-variation-result/test.xml
Expand Down
165 changes: 96 additions & 69 deletions docs/libraries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,76 @@ Beside ``osc.standard`` provided by OpenSCENARIO 2 (which we divide into ``osc.s

Additional features can be implemented by defining your own library.

``osc.helpers``
---------------

Gazebo
------

The library contains actions to interact with the `Gazebo Simulation <https://gazebosim.org/>`_. Import it with ``import osc.gazebo``. It's provided by the package :repo_link:`scenario_execution_gazebo`.

Actions
^^^^^^^

``actor_exists()``
""""""""""""""""""

Waits for an actor to exist within simulation.

- ``entity_name``: Entity name within simulation
- ``world_name: string``: Gazebo world name (default: ``default``)

``osc_object.delete()``
"""""""""""""""""""""""

Delete an object from the simulation.

- ``entity_name``: Entity name within simulation
- ``world_name: string``: Gazebo world name (default: ``default``)

``osc_object.relative_spawn()``
"""""""""""""""""""""""""""""""

Spawn an actor relative to a given ``frame_id`` within simulation (at a specified ``distance`` in front of ``frame_id``).

- ``frame_id``: The frame Id to spawn the actor relative to. (default: ``base_link``)
- ``parent_frame_id``: The parent frame ID against which movement is evaluated. (default: ``map``)
- ``distance``: distance value relative to the frame_id at which to spawn the new actor (default: 1.0)
- ``world_name: string``: Gazebo world name (default: ``default``)
- ``model: string``: Model definition
- ``xacro_arguments: string``: (optional) Comma-separated list of argument key:=value pairs

``osc_object.spawn()``
""""""""""""""""""""""

Spawn an actor within simulation.

- ``spawn_pose: pose_3d``: Pose of the spawned actor.
- ``world_name: string``: Gazebo world name (default: ``default``)
- ``model: string``: Model definition
- ``xacro_arguments: string``: (optional) Comma-separated list of argument key:=value pairs

.. note::

The model definition can be specified in different formats:

- ``file://<path-to-model>``: Local path to model file
- ``model://<path-to-model>``: Path relative to available model search paths
- ``<package-name>://<path-to-model>``: Path relative to an available package (e.g. :repo_link:`simulation/gazebo/test_scenario_execution_gazebo/scenarios/test_spawn_exists_delete.osc`)
- ``https:://fuel``: Model from `fuel.gazebosim.org <https://app.gazebosim.org/>`__ (e.g. ``https://fuel.gazebosim.org/1.0/OpenRobotics/models/Beer``)

If the file ending is ``.xacro`` the model is forwarded to `xacro <https://wiki.ros.org/xacro>`__ before getting spawned.

``wait_for_sim()``
""""""""""""""""""
Wait for simulation to become active (checks for simulation clock).

- ``world_name: string``: Gazebo world name (default: ``default``)
- ``timeout: time``: time to wait for the simulation. return failure afterwards. (default: ``60s``)


Helpers
-------

The library contains basic helper methods. Import it with ``import osc.helpers``.

Actions
^^^^^^^
Expand All @@ -31,18 +99,39 @@ Run a process. Reports `running` while the process has not finished.
- ``command: string``: Command to execute


``osc.robotics``
----------------
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.

- ``file_name: string``: File name to check


Robotics
--------

The library contains elements reusable in different robotic contexts. Import it with ``import osc.robotics``. It is provided by the package :repo_link:`scenario_execution`.

Actors
^^^^^^

``robot``
""""""""""""""""""""""""""""
"""""""""
A general robot actor.

``osc.ros``
-----------

ROS
---

The library contains actions to interact with ROS nodes. Import it with ``import osc.ros``. It is provided by the package :repo_link:`scenario_execution_ros`.

Actors
^^^^^^
Expand Down Expand Up @@ -228,65 +317,3 @@ In the background, this action uses `wait_for_data() <https://py-trees-ros.readt
Wait for topics to get available (i.e. publisher gets available).

- ``topics: list of string``: List of topics to wait for

``osc.gazebo``
--------------

Actions
^^^^^^^

``actor_exists()``
""""""""""""""""""

Waits for an actor to exist within simulation.

- ``entity_name``: Entity name within simulation
- ``world_name: string``: Gazebo world name (default: ``default``)

``osc_object.delete()``
"""""""""""""""""""""""

Delete an object from the simulation.

- ``entity_name``: Entity name within simulation
- ``world_name: string``: Gazebo world name (default: ``default``)

``osc_object.relative_spawn()``
"""""""""""""""""""""""""""""""

Spawn an actor relative to a given ``frame_id`` within simulation (at a specified ``distance`` in front of ``frame_id``).

- ``frame_id``: The frame Id to spawn the actor relative to. (default: ``base_link``)
- ``parent_frame_id``: The parent frame ID against which movement is evaluated. (default: ``map``)
- ``distance``: distance value relative to the frame_id at which to spawn the new actor (default: 1.0)
- ``world_name: string``: Gazebo world name (default: ``default``)
- ``model: string``: Model definition
- ``xacro_arguments: string``: (optional) Comma-separated list of argument key:=value pairs

``osc_object.spawn()``
""""""""""""""""""""""

Spawn an actor within simulation.

- ``spawn_pose: pose_3d``: Pose of the spawned actor.
- ``world_name: string``: Gazebo world name (default: ``default``)
- ``model: string``: Model definition
- ``xacro_arguments: string``: (optional) Comma-separated list of argument key:=value pairs

.. note::

The model definition can be specified in different formats:

- ``file://<path-to-model>``: Local path to model file
- ``model://<path-to-model>``: Path relative to available model search paths
- ``<package-name>://<path-to-model>``: Path relative to an available package (e.g. :repo_link:`simulation/gazebo/test_scenario_execution_gazebo/scenarios/test_spawn_exists_delete.osc`)
- ``https:://fuel``: Model from `fuel.gazebosim.org <https://app.gazebosim.org/>`__ (e.g. ``https://fuel.gazebosim.org/1.0/OpenRobotics/models/Beer``)

If the file ending is ``.xacro`` the model is forwarded to `xacro <https://wiki.ros.org/xacro>`__ before getting spawned.

``wait_for_sim()``
""""""""""""""""""
Wait for simulation to become active (checks for simulation clock).

- ``world_name: string``: Gazebo world name (default: ``default``)
- ``timeout: time``: time to wait for the simulation. return failure afterwards. (default: ``60s``)
1 change: 1 addition & 0 deletions libs/scenario_execution_os/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include scenario_execution_os/lib_osc/*.osc
8 changes: 8 additions & 0 deletions libs/scenario_execution_os/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Scenario Execution Library for OS interaction

The `scenario_execution_os` package provides actions to interact with the operating system.

It provides the following scenario execution library:

- `os.osc`: Actions to interact with operating system

21 changes: 21 additions & 0 deletions libs/scenario_execution_os/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>scenario_execution_os</name>
<version>1.1.0</version>
<description>Scenario Execution library for OS interactions</description>
<author email="[email protected]">Intel Labs</author>
<maintainer email="[email protected]">Intel Labs</maintainer>
<license file="../../LICENSE">Apache-2.0</license>

<depend>scenario_execution</depend>

<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
Empty file.
15 changes: 15 additions & 0 deletions libs/scenario_execution_os/scenario_execution_os/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (C) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import os
import py_trees


class CheckFileExists(py_trees.behaviour.Behaviour):
"""
Check existance of a file
"""

def __init__(self, name, file_name):
super().__init__(name)
self.file_name = file_name

def update(self) -> py_trees.common.Status:
if os.path.isfile(self.file_name):
return py_trees.common.Status.SUCCESS
else:
return py_trees.common.Status.FAILURE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0


def get_osc_library():
return 'scenario_execution_os', 'os.osc'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import osc.standard.base

action check_file_exists:
# report success if a file exists
file_name: string # file to check
4 changes: 4 additions & 0 deletions libs/scenario_execution_os/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/scenario_execution_os
[install]
install_scripts=$base/lib/scenario_execution_os
48 changes: 48 additions & 0 deletions libs/scenario_execution_os/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (C) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

""" Setup python package """
from setuptools import find_namespace_packages, setup

PACKAGE_NAME = 'scenario_execution_os'

setup(
name=PACKAGE_NAME,
version='1.1.0',
packages=find_namespace_packages(),
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + PACKAGE_NAME]),
('share/' + PACKAGE_NAME, ['package.xml'])
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='Intel Labs',
maintainer_email='[email protected]',
description='Scenario Execution library for OS interactions',
license='Apache License 2.0',
tests_require=['pytest'],
include_package_data=True,
entry_points={
'scenario_execution.actions': [
'check_file_exists = scenario_execution_os.actions.check_file_exists:CheckFileExists',
],
'scenario_execution.osc_libraries': [
'os = '
'scenario_execution_os.get_osc_library:get_osc_library',
]
},
)
Loading
Loading