Metadata-Version: 2.4
Name: navground_learning
Version: 0.2.0
Summary: A Python package that interfaces navground with ML-libraries to learn navigating using IL and RL.
Author-email: Jerome Guzzi <jerome@idsia.ch>
Maintainer-email: Jerome Guzzi <jerome@idsia.ch>
License: MIT License
        
        Copyright (c) 2024 IDSIA Robotics Group
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/idsia-robotics/navground_learning
Project-URL: Documentation, https://idsia-robotics.github.io/navground_learning
Project-URL: Repository, https://github.com/idsia-robotics/navground_learning.git
Project-URL: Bug Tracker, https://github.com/idsia-robotics/navground_learning/issues
Project-URL: Changelog, https://github.com/idsia-robotics/navground_learning/blob/main/CHANGELOG.md
Keywords: navigation,navground,gymnasium,pettingzoo,torchrl,imitation-learning,reinforcement-learning
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Education
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: gymnasium>=1.0.0
Requires-Dist: navground>=0.6.0
Requires-Dist: pettingzoo>=1.24.3
Provides-Extra: rl
Requires-Dist: stable-baselines3>=2.4.0; extra == "rl"
Requires-Dist: SuperSuit>=3.9.3; extra == "rl"
Provides-Extra: il
Requires-Dist: imitation>=1.0.0; extra == "il"
Requires-Dist: SuperSuit>=3.9.3; extra == "il"
Provides-Extra: inference
Requires-Dist: onnxruntime>=1.20.0; extra == "inference"
Requires-Dist: onnx; extra == "inference"
Provides-Extra: torchrl
Requires-Dist: benchmarl; extra == "torchrl"
Requires-Dist: torchrl; extra == "torchrl"
Provides-Extra: all
Requires-Dist: navground[all]; extra == "all"
Requires-Dist: pettingzoo>=1.24.3; extra == "all"
Requires-Dist: SuperSuit>=3.9.3; extra == "all"
Requires-Dist: stable-baselines3>=2.4.0; extra == "all"
Requires-Dist: imitation>=1.0.0; extra == "all"
Requires-Dist: onnxruntime; extra == "all"
Requires-Dist: torch>=2.4; extra == "all"
Requires-Dist: onnx; extra == "all"
Requires-Dist: tqdm; extra == "all"
Requires-Dist: benchmarl; extra == "all"
Requires-Dist: torchrl; extra == "all"
Requires-Dist: pandas; extra == "all"
Requires-Dist: matplotlib; extra == "all"
Dynamic: license-file

# navground_learning

A Python package that adds Imitation or Reinforcement Learning to the tools user can play with in the **Nav**igation Play**ground** [navground](https://github.com/idsia-robotics/navground).

The package provides configurable single-agent [Gymnasium](https://gymnasium.farama.org/index.html)  and multi-agent Parallel [PettingZoo](https://pettingzoo.farama.org/index.html) environments. Users, by combining navigation scenarios and sensors, can build any kind of environment where to learn navigation policies.

## Main features

- Single-agent Gymnasium environment that expose actions, obervations and rewards of a single agent in a navground scenario.
- Multi-agent PettingZoo environment that expose actions, observations and rewards of multiple agents, possibly heterogenous, in a navground scenario.
- Ability to execute a navigation policy in navground, with support for [ONNX](https://onnx.ai) and [Stable-Baselines3](https://stable-baselines3.readthedocs.io).
- User-extendable configuration for translating between navground commands/states and the POMDP actions/observations.
- Reward functions for navigation tasks.
- Import/export from/to YAML, like common in navground.
- Tools to evaluate the policies during and after training, inside and outside of the environments.

## Installation

```
pip install navground_learning[all]
```

We support Python>=3.10. Users should prefer Python<=3.12 because important third-party packages like Stable-BaseLine3 or PyTorch do not support Python3.13 yet.

## Example

Note that to run the example, you need to install the `rl` and `inference` optional dependecies:

```
pip install navground_learning[rl,inference]
```

which are installed if you installed `navground_learning[all]`.


The example instantiate the environment of [one of the tutorials](https://idsia-robotics.github.io/navground_learning/tutorials/corridor_with_obstacle.html), in which it trains a policy using `SAC`.
Then, it export the policy as an `ONNX`, which it uses to run a navground experiment, recording the trajectories to an HDF5 file.

```python
from navground.learning import evaluation, io
from navground.learning.examples import corridor_with_obstacle
from stable_baselines3 import SAC

# Creates a Gymnasium environment 
env = corridor_with_obstacle.get_env()
# Train using Stable-Baseline3
model = SAC("MlpPolicy", env).learn(total_timesteps=1_000)
# Export the model to ONNX
io.export_behavior(model, "model")

# Evaluate the policy with a navground experiment
exp = evaluation.make_experiment_with_env(env, policy="model/policy.onnx")
exp.number_of_runs = 100
exp.record_config.pose = True
exp.save_directory = '.'
exp.run()
```
## Documentation

The [project documentation](https://idsia-robotics.github.io/navground_learning) in addition to the API reference, includes 
several [tutorials](https://idsia-robotics.github.io/navground_learning/tutorials) of Machine-Learning policies in navigation, ranging from very basics to complex multi-agent scenarios. 

## License and copyright

This software is free for reuse according to the attached MIT license.

## Acknowledgement and disclaimer

The work was supported in part by [REXASI-PRO](https://rexasi-pro.spindoxlabs.com) H-EU project, call HORIZON-CL4-2021-HUMAN-01-01, Grant agreement no. 101070028.

<img src="https://rexasi-pro.spindoxlabs.com/wp-content/uploads/2023/01/Bianco-Viola-Moderno-Minimalista-Logo-e1675187551324.png"  width="300">

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.
