Git Product home page Git Product logo

scenario_execution's Introduction

Scenario Execution

Super-Linter OpenSSF Scorecard

Scenario execution is a backend- and middleware-agnostic library written in Python based on the generic scenario description language OpenSCENARIO 2 and pytrees. 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.

To give an impression of the functionality of scenario execution, the following animation shows an example scenario with a turtlebot-like robot in simulation using Nav2 and ROS as middleware to navigate towards a specified navigation goal in a simulated warehouse environment. Once the robot reaches a reference position a box is spawned in front of the robot as an unmapped static obstacle that needs to be avoided. Upon arrival of the goal position, the scenario ends and the simulation gets cleaned up.

scenario execution in action

Documentation

Please find the documentation here.

Setup

Installation from source as ROS 2 workspace

Clone this repository, update its submodules by running:

git submodule update --init

install the necessary dependencies:

rosdep install  --from-paths . --ignore-src
pip3 install -r requirements.txt

and build it

colcon build

How to run

First, build the packages:

colcon build
source install/setup.bash

To launch a scenario with ROS2:

ros2 launch scenario_execution_ros scenario_launch.py scenario:=examples/example_scenario/hello_world.osc live_tree:=True

scenario_execution's People

Contributors

abra00 avatar fmirus avatar fred-labs avatar georgepos avatar michaelbeale-il avatar nikhil-singhal-06 avatar pipinet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

scenario_execution's Issues

should remove signal in ScenarioExecution __init__ when start in a thread

signal should implement by outside when it need.

in my case i start ScenarioExecution in thread, and i run it without ROS2.

The following code should be executed where it is needed externally, not here

class ScenarioExecution(object):
    """
    Base class for scenario execution.
    Override method run() and method setup_behaviour_tree() to adapt to other middlewares.
    This class can also be executed standalone
    """

    def __init__(self,
                 debug: bool,
                 log_model: bool,
                 live_tree: bool,
                 scenario_file: str,
                 output_dir: str,
                 dry_run=False,
                 render_dot=False,
                 setup_timeout=py_trees.common.Duration.INFINITE,
                 tick_period: float = 0.1,
                 logger=None) -> None:

        def signal_handler(sig, frame):                                     <----------here
            self.on_scenario_shutdown(False, "Aborted").       <----------here

        signal.signal(signal.SIGHUP, signal_handler)               <----------here
        signal.signal(signal.SIGTERM, signal_handler)            <----------here

        self.current_scenario_start = None

Github Action: Post video of simulation run in PR

There is already the possibility to create a video of a scenario run within a github action run and publish it as an artifact.
To achieve a high level of convenience, the video would ideally also be posted as a comment to the PR, to be directly visible to the user for further analysis.

Required Skills

  • CI
  • github actions

False text.xml output

If the scenario is not successful or is not executed properly, the generated test.xml file is sometimes incorrect and only contains testsuite tags.

test xml

Version information (please complete the following information):

  • OS: Ubuntu 22.04
  • ROS version: humble

create pip package of scenario_execution_base

Is your feature request related to a problem? Please describe.

Currently, we only offer how to run tutorials of scenario execution with ROS2. To support running scenario execution as standalone python library (without ROS 2), scenario_execution_base should be available as pip package in PyPi.

Describe the solution you'd like

Make scenario_execution_base available as pip package in PyPi and add corresponding section to the how to run page of the documentation.

make scenario_variation and scenario_batch_execution executable

Is your feature request related to a problem? Please describe.
Scripts scenario_variation and scenario_batch_execution inside scenario_coverage package needs ros2 and python prefix to run respectively.

Describe the solution you'd like
Both the scripts could be stand alone executables to run directly from command line.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Add support for non-ros py-trees-viewer

Currently there are two modes of viewing the current state of a behavior tree.

With py_trees_js it is possible to visualize the behavior tree without the need for ROS2, using a web-socket.

Extend scenario-execution to support a py-trees-js-based visualization.

Required Skills

  • Javascript
  • network communication
  • optional: python, C++, Qt

Challenges

While the visualization parts are already available, the main challenge is to send the required data from scenario-execution to the visualization. As an extension the visualization might also be provided by an Qt/Rviz2 plugin.

Navigation action does not stop properly with scenario_execution_control

Describe the bug
When controlling AMR navigation scenarios with scenario_execution_control via rviz and the user stops the scenario during execution of a navigation action, it is not properly stopped, but the robot continues to navigate to its goal although the scenario was already stopped. Hence, the cleanup function of the nav_to_pose action is not properly called in this case. The problem seems to be related to Threading in the scenario_runner.

To Reproduce
Run the scenario control example according to the corresponding tutorial and stop the scenario while the robot is navigating towards a goal.

Expected behavior
The robot should stop its current navigation mission immediately after the scenario is stopped from rviz.

Screenshots

scenario_control_nav_bug

Version information:

  • OS: Ubuntu 22.04
  • Version 1.0.0
  • ROS version: humble

Create AI usage example using scenario-execution

To show the versatility of scenario_execution we want to create an example that shows how scenarios can be used in AI training tasks.

Some ideas:

Required Skills

  • Python
  • basics of reinforcement learning (e.g. using gymnasium or other AI approaches

Challenges

Use scenario-execution to create many scenarios and show that robustness increases.

Control pedestrian movement in simulation

We want to have a reasonable pedestrian simulation, either with Gazebo or another simulator.

Gazebo Approach

Gazebo supports walking pedestrians (tutorial). scenario_execution should be able to control the movement.

Possible actions

  • move_along_path
  • move_to_pose

Required Skills

  • C++

Challenges

The task might require to at least partially understand the architecture of Gazebo in order to modify/create C++ plugins

Interface other simulators

At the moment only Gazebo and PyBullet are supported (through the library scenario_execution_gazebo and scenario_execution_pybullet).

We would like to support further simulations.

Potential simulators to support (list might get extended):

Required Skills

  • Python
  • (optional) simulator-specific knowledge
  • (optional) ROS2 basics

Challenges

Interfacing a new simulator through scenario-execution might be challenging because of the different design decisions. While e.g. Gazebo is "ticking" (i.e. moving forward in simulation time) stand-alone and publishing data to ROS2 directly (through network interfaces) others might need scenario-execution to tick (e.g. scenario_execution_pybullet).

run_external_process not usable from osc file

Describe the bug
Trying to use run_external_process() from a osc file fails
as it is said to be used in the helpers.osc as a string

To Reproduce
in a osc file use:
serial:
run_external_process() with:
keep(it.command == "ros2 run x y")

Expected behavior
an external command should be started successfully

Screenshots
If applicable, add screenshots to help explain your problem.

Version information (please complete the following information):

  • OS: [e.g. Ubuntu 22.04]
  • Version [e.g. 1.0.0]
  • ROS version: [e.g. humble]

Additional context
Add any other context about the problem here.

Extend support for simulations

Make simulation features accessible through scenario-execution (e.g. apply impulse, move)

Currently only basic features are available, like spawning or deleting actors.

Identify potential use-cases/functionality, implement simulator-specific actions.

Examples

  • Add impulse to actor
  • Move actor
  • check for collisions

Use cases

  • robot moving within a factory
  • humans within an office environment
  • last-mile delivery robots
  • ....

Required Skills

  • Python
  • understanding of potential challenges for robots

Generic approach for capturing datasets

Currently, the only supported method for capturing data with scenario execution is using ROS2 (using the action record_bag).

We want to support at least one other simulation, e.g. pybullet and provide a (generic) approach to capture data.

Example:

import osc.helpers
import osc.pybullet
import osc.data_writer # <-- new library

scenario example_pybullet:
    timeout(60s)
    sim: simulation_pybullet
    actor1: actor_pybullet
    writer: kitti_writer("./my_dataset", "odometry1") # <-- new actor
    do serial:
        sim.initialize("plane.urdf")
        actor1.spawn("husky/husky.urdf", pose_3d(position: position_3d(z: 0.5)))
        parallel:
            sim.run()
            writer.capture() # <-- new action
            actor1.set_joint_motor_control(5mps, 1)
            serial:
                actor1.distance_traveled(2m)
                emit end

In this example only the odometry might be captured (as no image provider is instantiated).

Different data annotation formats might be supported, e.g.:

  • kitti
  • csv/jpg
  • ...

Stretch Goal

Create example on how to use captured dataset to train an AI.

log_check excpected message printed in rosout

Describe the bug
when using log_check to find a message in rosout, scenario_execution will print out
an instantiate action message containing the message that needs to be found in rosout

To Reproduce
use log_check in osc file and echo the rosout topic

Expected behavior
i think that the log_check should also look at the name field from rosout instead of just msg.msg

Screenshots
If applicable, add screenshots to help explain your problem.

Version information (please complete the following information):

  • OS: [e.g. Ubuntu 22.04]
  • Version [e.g. 1.0.0]
  • ROS version: [e.g. humble]

Additional context
Add any other context about the problem here.

Slow Parsing when using many imports.

Describe the bug
When using library imports, parsing get significantly slower.

To Reproduce
Use scenario with many large scenario library imports.

Expected behavior
Parsing finished within 2-3s.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.