Name | pytorch-icem JSON |
Version |
0.1.0
JSON |
| download |
home_page | |
Summary | Improved Cross Entropy Method (iCEM) implemented in pytorch |
upload_time | 2023-12-15 22:02:39 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.6 |
license | Copyright (c) 2023 University of Michigan ARM Lab 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. |
keywords |
icem
mpc
pytorch
control
robotics
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PyTorch MPPI Implementation
This repository implements the improved Cross Entropy Method (iCEM)
with approximate dynamics in pytorch, from [this paper](https://martius-lab.github.io/iCEM/).
MPPI typically requires actual
trajectory samples, but [this paper](https://martius-lab.github.io/iCEM/)
showed that it could be done with approximate dynamics (such as with a neural network)
using importance sampling.
Thus it can be used in place of other trajectory optimization methods
such as the Cross Entropy Method (CEM), or random shooting.
# Related projects
- [pytorch CEM](https://github.com/LemonPi/pytorch_cem) - alternative sampling based MPC
- [pytorch MPPI](https://github.com/UM-ARM-Lab/pytorch_mppi) - alternative sampling based MPC
- [iCEM](https://github.com/martius-lab/iCEM) - original paper's numpy implementation and experiments code
# Installation
```shell
pip install pytorch-icem
```
for running tests, install with
```shell
pip install pytorch-icem[test]
```
for development, clone the repository then install in editable mode
```shell
pip install -e .
```
# Usage
See `tests/pendulum_approximate_continuous.py` for usage with a neural network approximating
the pendulum dynamics. Basic use case is shown below
```python
from pytorch_icem import iCEM
# create controller with chosen parameters
ctrl = icem.iCEM(dynamics, terminal_cost, nx, nu, sigma=sigma,
warmup_iters=10, online_iters=10,
num_samples=N_SAMPLES, num_elites=10, horizon=TIMESTEPS, device=d, )
# assuming you have a gym-like env
obs = env.reset()
for i in range(100):
action = ctrl.command(obs)
obs, reward, done, _, _ = env.step(action.cpu().numpy())
```
# Requirements
- pytorch (>= 1.0)
- `next state <- dynamics(state, action)` function (doesn't have to be true dynamics)
- `state` is `K x nx`, `action` is `K x nu`
- `trajectory cost <- cost(state, action)` function for the whole state action trajectory, T is the horizon
- `cost` is `K x 1`, state is `K x T x nx`, `action` is `K x T x nu`
# Features
- Parallel/batch pytorch implementation for accelerated sampling
Raw data
{
"_id": null,
"home_page": "",
"name": "pytorch-icem",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "Sheng Zhong <zhsh@umich.edu>, Thomas Power <tpower@umich.edu>",
"keywords": "icem,mpc,pytorch,control,robotics",
"author": "",
"author_email": "Sheng Zhong <zhsh@umich.edu>, Thomas Power <tpower@umich.edu>",
"download_url": "https://files.pythonhosted.org/packages/67/eb/f93cc1583c0da784722c76845dfd296792b6ca3353359e63329d52d5b0d3/pytorch_icem-0.1.0.tar.gz",
"platform": null,
"description": "# PyTorch MPPI Implementation\nThis repository implements the improved Cross Entropy Method (iCEM) \nwith approximate dynamics in pytorch, from [this paper](https://martius-lab.github.io/iCEM/). \n\nMPPI typically requires actual\ntrajectory samples, but [this paper](https://martius-lab.github.io/iCEM/)\nshowed that it could be done with approximate dynamics (such as with a neural network)\nusing importance sampling.\n\nThus it can be used in place of other trajectory optimization methods\nsuch as the Cross Entropy Method (CEM), or random shooting.\n\n\n# Related projects\n- [pytorch CEM](https://github.com/LemonPi/pytorch_cem) - alternative sampling based MPC\n- [pytorch MPPI](https://github.com/UM-ARM-Lab/pytorch_mppi) - alternative sampling based MPC \n- [iCEM](https://github.com/martius-lab/iCEM) - original paper's numpy implementation and experiments code\n\n\n# Installation\n```shell\npip install pytorch-icem\n```\nfor running tests, install with\n```shell\npip install pytorch-icem[test]\n```\nfor development, clone the repository then install in editable mode\n```shell\npip install -e .\n```\n\n# Usage\nSee `tests/pendulum_approximate_continuous.py` for usage with a neural network approximating\nthe pendulum dynamics. Basic use case is shown below\n\n```python\nfrom pytorch_icem import iCEM\n\n# create controller with chosen parameters\nctrl = icem.iCEM(dynamics, terminal_cost, nx, nu, sigma=sigma,\n warmup_iters=10, online_iters=10,\n num_samples=N_SAMPLES, num_elites=10, horizon=TIMESTEPS, device=d, )\n\n# assuming you have a gym-like env\nobs = env.reset()\nfor i in range(100):\n action = ctrl.command(obs)\n obs, reward, done, _, _ = env.step(action.cpu().numpy())\n```\n\n# Requirements\n- pytorch (>= 1.0)\n- `next state <- dynamics(state, action)` function (doesn't have to be true dynamics)\n - `state` is `K x nx`, `action` is `K x nu`\n- `trajectory cost <- cost(state, action)` function for the whole state action trajectory, T is the horizon\n - `cost` is `K x 1`, state is `K x T x nx`, `action` is `K x T x nu`\n\n# Features\n- Parallel/batch pytorch implementation for accelerated sampling\n",
"bugtrack_url": null,
"license": "Copyright (c) 2023 University of Michigan ARM Lab 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. ",
"summary": "Improved Cross Entropy Method (iCEM) implemented in pytorch",
"version": "0.1.0",
"project_urls": {
"Bug Reports": "https://github.com/UM-ARM-Lab/pytorch_icem/issues",
"Homepage": "https://github.com/UM-ARM-Lab/pytorch_icem",
"Source": "https://github.com/UM-ARM-Lab/pytorch_icem"
},
"split_keywords": [
"icem",
"mpc",
"pytorch",
"control",
"robotics"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "be95e79c59148f2528ee0a2f2e2d47067b26827a1dcdb82e8bcad819f0129aaf",
"md5": "757eb6c5305739460192307fc79f12d5",
"sha256": "d22309e0b8879b1e4f88787687631c03f1a7f01c639a7cc7134f87951794e180"
},
"downloads": -1,
"filename": "pytorch_icem-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "757eb6c5305739460192307fc79f12d5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 6271,
"upload_time": "2023-12-15T22:02:37",
"upload_time_iso_8601": "2023-12-15T22:02:37.109282Z",
"url": "https://files.pythonhosted.org/packages/be/95/e79c59148f2528ee0a2f2e2d47067b26827a1dcdb82e8bcad819f0129aaf/pytorch_icem-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "67ebf93cc1583c0da784722c76845dfd296792b6ca3353359e63329d52d5b0d3",
"md5": "581e488445e5733eb708a32978186903",
"sha256": "6ab86b351e2b8eb367d1698444a58d8112b1bbff98cab293d9d41b87ba422c35"
},
"downloads": -1,
"filename": "pytorch_icem-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "581e488445e5733eb708a32978186903",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 7723,
"upload_time": "2023-12-15T22:02:39",
"upload_time_iso_8601": "2023-12-15T22:02:39.011294Z",
"url": "https://files.pythonhosted.org/packages/67/eb/f93cc1583c0da784722c76845dfd296792b6ca3353359e63329d52d5b0d3/pytorch_icem-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-15 22:02:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "UM-ARM-Lab",
"github_project": "pytorch_icem",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pytorch-icem"
}