-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add SwimmerCost environment (#180)
* feat: add SwimmerCost environment This commit adds the SwimmerCost environment. This environment was based on the [swimmer environment](https://gymnasium.farama.org/environments/mujoco/swimmer/) of the [gymnasium library](https://gymnasium.farama.org). Compared to that environment, only the reward was changed so that a reference speed was tracked. * test: add 'SwimmerCost' tests * docs: improve docs * test: rename 'Swimmer' test * docs: fix documentation error * docs: improve environments documentation
- Loading branch information
Showing
21 changed files
with
352 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.. include:: ../../../../stable_gym/envs/mujoco/swimmer_cost/README.md | ||
:parser: myst_parser.sphinx_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
"""Stable Gym gymnasium environments that are based on classical control theory | ||
problems. | ||
""" | ||
"""Stable Gym gymnasium environments based on classical control problems or | ||
`classical control`_ environments found in the :gymnasium:`gymnasium <>` library. | ||
.. _`classical control`: https://gymnasium.farama.org/environments/classic_control | ||
""" # noqa: E501 | ||
from stable_gym.envs.classic_control.cartpole_cost.cartpole_cost import CartPoleCost | ||
from stable_gym.envs.classic_control.ex3_ekf.ex3_ekf import Ex3EKF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
gymnasium==0.28.1 | ||
gymnasium[classic_control]==0.28.1 | ||
matplotlib==3.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
gymnasium==0.28.1 | ||
gymnasium[classic_control]==0.28.1 | ||
matplotlib==3.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Stable Gym gymnasium environments that are based on `Mujoco`_ or `Mujoco gymnasium`_ environments. | ||
.. _`Mujoco`: https://mujoco.org | ||
.. _`Mujoco gymnasium`: https://gymnasium.farama.org/environments/mujoco | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SwimmerCost gymnasium environment | ||
|
||
<div align="center"> | ||
<img src="https://github.com/rickstaa/stable-gym/assets/17570430/dccd73b4-c97e-46ce-ba0d-4a1328c0aefe" alt="swimmer" width="200px"> | ||
</div> | ||
</br> | ||
|
||
An actuated two-jointed swimmer. This environment corresponds to the [Swimmer-v4](https://gymnasium.farama.org/environments/mujoco/swimmer) environment included in the [gymnasium package](https://gymnasium.farama.org/). It is different in the fact that: | ||
|
||
* The objective was changed to a speed-tracking task. To do this, the reward is replaced with a cost. This cost is the squared difference between the swimmer's forward speed and a reference value (error). | ||
|
||
The rest of the environment is the same as the original Swimmer environment. Below, the modified cost is described. For more information about the environment (e.g. observation space, action space, episode termination, etc.), please refer to the [gymnasium library](https://gymnasium.farama.org/environments/mujoco/swimmer/). | ||
|
||
## Cost function | ||
|
||
The cost function of this environment is designed in such a way that it tries to minimize the error between the swimmer's forward speed and a reference value. The cost function is defined as: | ||
|
||
$$ | ||
cost = w\_{forward} \times (x\_{speed} - x\_{reference\_speed})^2 + w\_{ctrl} \times c\_{ctrl} | ||
$$ | ||
|
||
## How to use | ||
|
||
This environment is part of the [Stable Gym package](https://github.com/rickstaa/stable-gym). It is therefore registered as the `stable_gym:SwimmerCost-v1` gymnasium environment when you import the Stable Gym package. If you want to use the environment in stand-alone mode, you can register it yourself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Modified version of the swimmer Mujoco environment in v0.28.1 of the | ||
`gymnasium library <https://gymnasium.farama.org/environments/mujoco/swimmer>`_. | ||
This modification was first described by `Han et al. 2020 <https://arxiv.org/abs/2004.14288>`_. | ||
In this modified version: | ||
- The objective was changed to a speed-tracking task. To do this, the reward is replaced with a cost. | ||
This cost is the squared difference between the swimmer's forward speed and a reference value (error). | ||
""" # noqa: E501 | ||
from stable_gym.envs.mujoco.swimmer_cost.swimmer_cost import SwimmerCost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
gymnasium==0.28.1 | ||
gymnasium[mujoco]==0.28.1 | ||
matplotlib==3.7.0 |
Oops, something went wrong.