Skip to content

idsia-robotics/navground_onnx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

navground_onnx

This package contains a c++ implementation of navground_learning PolicyBehavior (called CppPolicy) that depends only on navground_core and onnxruntime.

Install

  1. Install or build navground_core from source following the instructions and source the navground setup script
  2. Setup navground (depending on the operating system and on how you installed navground).
  3. Install onnxruntime.
  4. Build navground_onnx:
  • using colcon:
    $ colcon build --packages-select navground_onnx
  • using cmake:
    $ cmake -DCMAKE_BUILD_TYPE=Release <path to navground_onnx>
    $ cmake --build .
    

First steps

Verify that the behavior is installed by running

$ navground info --behaviors CppPolicy --properties --description
Installed components
====================
Behaviors
---------
CppPolicy
    flat: false (bool)
      Whether to flatten the observations
    include_angular_speed: false (bool)
      Whether to include the current angular speed in the observations
    include_target_direction: false (bool)
      Whether to include the target direction in the observations
    include_target_distance: false (bool)
      Whether to include the target distance in the observations
    include_target_speed: false (bool)
      Whether to include the target speed in the observations
    include_velocity: false (bool)
      Whether to include the current velocity in the observations
    max_acceleration: 10 (float)
      The upper bound of the acceleration.
    max_angular_acceleration: 0 (float)
      The upper bound of the angular acceleration.
    policy_path:  (str)
      Path to the onnx model
    shared: false (bool)
      Whether to share the policy with similar agents
    use_acceleration_action: false (bool)
      Whether actions are accelerations.

which prints the list of properties exposed by CppPolicy and their default values.

Usage

Follow the navground documentation to configure the behavior from YAML, e.g.,

...
behavior:
  type: CppPolicy
  policy_path: 'policy.onnx'
  shared: true
  ...

or from C++.

If shared is set, the same onnx model is shared between all agents/behaviors that have the same configuration and inference happens in parallel, therefore reducing inference costs significantly (e.g., by about factor 5 for crossing with 20 agents (45 us vs 200 us), which in turn reduces the total simulation cost by factor 3 (70 us vs 225 us)). Note that the onnx model finalizes its initialization when the first inference is requested for the first agent that is sharing the policy.

If shared is not set, each behavior instantiates its own copy of the onnx policy and perform inference independently.

Examples

The directory examples contains few examples of experiments configured to use CppPolicy. The policy have been trained in the corresponding navground_learning tutorials.

Execute them using the navground CLI, like:

$ navground run examples/crossing/experiment.yaml --chdir
Performing experiment ...
Experiment done
Duration: 0.0931841 s

Acknowledgement and disclaimer

The work was supported in part by REXASI-PRO H-EU project, call HORIZON-CL4-2021-HUMAN-01-01, Grant agreement no. 101070028.

The work has been partially funded by the European Union. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Commission. Neither the European Union nor the European Commission can be held responsible for them.

About

Provides a C++ navigation behavior that evaluates a ONNX model.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published