Skip to content

Commit 168c34e

Browse files
Set render=True by default for panda gym envs (#311)
* correct visualization by adding render:True to panda_gym envs in absense of --no-render * remove buried README note now that args are passed under the hood * update changelog with changes for panda-gym visualization * handle uninitialized env_kwargs * add comment * fix typo changelog Co-authored-by: Quentin GALLOUÉDEC <gallouedec.quentin@gmail.com> Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
1 parent 99fcfbe commit 168c34e

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### New Features
66
- Specifying custom policies in yaml file is now supported (@Rick-v-E)
77
- Added ``monitor_kwargs`` parameter
8+
- Handle the `env_kwargs` of `render:True` under the hood for panda-gym v1 envs in `enjoy` replay to match visualzation behavior of other envs
89

910
### Bug fixes
1011
- Allow `python -m rl_zoo3.cli` to be called directly
@@ -239,7 +240,7 @@
239240
- Clarify n_evaluations help text (@jkterry)
240241
- Simplified hyperparameters files making use of defaults
241242
- Added new TQC+HER agents
242-
- Add `panda-gym`environments (@qgallouedec)
243+
- Add `panda-gym` environments (@qgallouedec)
243244

244245
## Release 1.0 (2021-03-17)
245246

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,6 @@ We used the v1 environments.
516516
|----------|-------------|-------------------|-----------|------------|------------|
517517
| HER+TQC | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
518518

519-
To visualize the result, you can pass `--env-kwargs render:True` to the enjoy script.
520-
521519

522520
### MiniGrid Envs
523521

rl_zoo3/exp_manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,11 @@ def is_robotics_env(env_id: str) -> bool:
509509
entry_point = gym.envs.registry.env_specs[env_id].entry_point # pytype: disable=module-attr
510510
return "gym.envs.robotics" in str(entry_point) or "panda_gym.envs" in str(entry_point)
511511

512+
@staticmethod
513+
def is_panda_gym(env_id: str) -> bool:
514+
entry_point = gym.envs.registry.env_specs[env_id].entry_point # pytype: disable=module-attr
515+
return "panda_gym.envs" in str(entry_point)
516+
512517
def _maybe_normalize(self, env: VecEnv, eval_env: bool) -> VecEnv:
513518
"""
514519
Wrap the env into a VecNormalize wrapper if needed

rl_zoo3/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ def create_test_env(
231231
vec_env_cls = SubprocVecEnv
232232
# start_method = 'spawn' for thread safe
233233

234+
# panda-gym is based on pybullet, whose rendering requires to be configure at initialization
235+
if ExperimentManager.is_panda_gym(env_id) and should_render:
236+
if env_kwargs is None:
237+
env_kwargs = {"render": True}
238+
else:
239+
env_kwargs["render"] = True
240+
234241
env = make_vec_env(
235242
env_id,
236243
n_envs=n_envs,

0 commit comments

Comments
 (0)