isaac-sim / IsaacLab

Unified framework for robot learning built on NVIDIA Isaac Sim
https://isaac-sim.github.io/IsaacLab
Other
1.85k stars 707 forks source link

[Bug Report] Sb3VecEnvWrapper overwrites action_space #609

Closed llinauer closed 2 months ago

llinauer commented 2 months ago

If you are submitting a bug report, please fill in the following details and use the tag [bug].

Describe the bug

The Sb3VecEnvWrapper (defined in https://github.com/isaac-sim/IsaacLab/blob/691b9e81c632b25ffefb40805029e2a5f88403e7/source/extensions/omni.isaac.lab_tasks/omni/isaac/lab_tasks/utils/wrappers/sb3.py#L81) calls the is_bounded method of the action_space of the underlying environment and checks if the return is not "both". However, the return value of the is_bounded method (defined here https://github.com/Farama-Foundation/Gymnasium/blob/e2c89a1896cc9f575abe5f1b3c799b6a718364af/gymnasium/spaces/box.py#L320, version 0.29.0) is boolean and this conditional always evaluates to True. This causes the action_space to be overwritten and becoming a Box(-100.0, 100.0).

Rather, "both" should be the argument of is_bounded and it should be checked if the return value is not True.

Steps to reproduce

Please try to provide a minimal example to reproduce the bug. Error messages and stack traces are also helpful.

Minimal example:

import argparse
from omni.isaac.lab.app import AppLauncher

app_launcher = AppLauncher(argparse.Namespace())
simulation_app = app_launcher.app

import gymnasium as gym
import omni.isaac.lab_tasks  # noqa: F401
from omni.isaac.lab_tasks.utils import parse_env_cfg
from omni.isaac.lab_tasks.utils.wrappers.sb3 import Sb3VecEnvWrapper

env_cfg = parse_env_cfg("Isaac-Cartpole-Direct-v0", use_gpu=False, num_envs=1, use_fabric=True)
env = gym.make("Isaac-Cartpole-Direct-v0", cfg=env_cfg, render_mode="rgb_array")
env.action_space = gym.spaces.Box(low=-1, high=1, shape=(1,))
print(env.action_space)
env = Sb3VecEnvWrapper(env)
print(env.action_space)

System Info

Describe the characteristic of your environment:

Additional context

Checklist

Acceptance Criteria

Add the criteria for which this task is considered done. If not known at issue creation time, you can add this once the issue is assigned.

Mayankm96 commented 2 months ago

Please check the fix in #610. Thanks for reporting!