Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default_camera_config argument on Swimmer, InvertedPendulum & InvertedDoublePendulum #854

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion gymnasium/envs/mujoco/inverted_double_pendulum_v5.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
__credits__ = ["Kallinteris-Andreas"]

from typing import Dict, Union

import numpy as np

from gymnasium import utils
Expand Down Expand Up @@ -136,6 +138,7 @@ class InvertedDoublePendulumEnv(MujocoEnv, utils.EzPickle):
## Version History
* v5:
- Minimum `mujoco` version is now 2.3.3.
- Added `default_camera_config` argument, a dictionary for setting the `mj_camera` properties, mainly useful for custom environments.
- Added `frame_skip` argument, used to configure the `dt` (duration of `step()`), default varies by environment check environment documentation pages.
- Fixed bug: `healthy_reward` was given on every step (even if the Pendulum is unhealthy), now it is only given if the DoublePendulum is healthy (not terminated)(related [Github issue](https://github.com/Farama-Foundation/Gymnasium/issues/500)).
- Excluded the `qfrc_constraint` ("constraint force") of the hinges from the observation space (as it was always 0, thus providing no useful information to the agent, resulting is slightly faster training) (related [Github issue](https://github.com/Farama-Foundation/Gymnasium/issues/228)).
Expand All @@ -162,6 +165,7 @@ def __init__(
self,
xml_file: str = "inverted_double_pendulum.xml",
frame_skip: int = 5,
default_camera_config: Dict[str, Union[float, int]] = {},
healthy_reward: float = 10.0,
reset_noise_scale: float = 0.1,
**kwargs,
Expand All @@ -178,7 +182,7 @@ def __init__(
xml_file,
frame_skip,
observation_space=observation_space,
default_camera_config=DEFAULT_CAMERA_CONFIG,
default_camera_config=default_camera_config,
**kwargs,
)

Expand Down
6 changes: 5 additions & 1 deletion gymnasium/envs/mujoco/inverted_pendulum_v5.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
__credits__ = ["Kallinteris-Andreas"]

from typing import Dict, Union

import numpy as np

from gymnasium import utils
Expand Down Expand Up @@ -115,6 +117,7 @@ class InvertedPendulumEnv(MujocoEnv, utils.EzPickle):
* v5:
- Minimum `mujoco` version is now 2.3.3.
- Added support for fully custom/third party `mujoco` models using the `xml_file` argument (previously only a few changes could be made to the existing models).
- Added `default_camera_config` argument, a dictionary for setting the `mj_camera` properties, mainly useful for custom environments.
- Added `env.observation_structure`, a dictionary for specifying the observation space compose (e.g. `qpos`, `qvel`), useful for building tooling and wrappers for the MuJoCo environments.
- Added `frame_skip` argument, used to configure the `dt` (duration of `step()`), default varies by environment check environment documentation pages.
- Fixed bug: `healthy_reward` was given on every step (even if the Pendulum is unhealthy), now it is only given if the Pendulum is healthy (not terminated) (related [Github issue](https://github.com/Farama-Foundation/Gymnasium/issues/500)).
Expand All @@ -140,6 +143,7 @@ def __init__(
self,
xml_file: str = "inverted_pendulum.xml",
frame_skip: int = 2,
default_camera_config: Dict[str, Union[float, int]] = DEFAULT_CAMERA_CONFIG,
reset_noise_scale: float = 0.01,
**kwargs,
):
Expand All @@ -153,7 +157,7 @@ def __init__(
xml_file,
frame_skip,
observation_space=observation_space,
default_camera_config=DEFAULT_CAMERA_CONFIG,
default_camera_config=default_camera_config,
**kwargs,
)

Expand Down
13 changes: 12 additions & 1 deletion gymnasium/envs/mujoco/swimmer_v5.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
__credits__ = ["Kallinteris-Andreas", "Rushiv Arora"]

from typing import Dict, Union

import numpy as np

from gymnasium import utils
Expand Down Expand Up @@ -169,6 +171,7 @@ def __init__(
self,
xml_file: str = "swimmer.xml",
frame_skip: int = 4,
default_camera_config: Dict[str, Union[float, int]] = {},
forward_reward_weight: float = 1.0,
ctrl_cost_weight: float = 1e-4,
reset_noise_scale: float = 0.1,
Expand All @@ -179,6 +182,7 @@ def __init__(
self,
xml_file,
frame_skip,
default_camera_config,
forward_reward_weight,
ctrl_cost_weight,
reset_noise_scale,
Expand All @@ -195,7 +199,14 @@ def __init__(
exclude_current_positions_from_observation
)

MujocoEnv.__init__(self, xml_file, frame_skip, observation_space=None, **kwargs)
MujocoEnv.__init__(
self,
xml_file,
frame_skip,
observation_space=None,
default_camera_config=default_camera_config,
**kwargs,
)

self.metadata = {
"render_modes": [
Expand Down
Loading