Source code for objectrl.utils.environment.metaworld_wrappers
import gymnasium as gym
[docs]
class SparsifyRewardWrapper(gym.Wrapper):
"""
Gymnasium wrapper for Meta-World environments
that replaces reward with the binary success signal.
Args:
env : gym.Env
The Meta-World environment to wrap.
"""
[docs]
def __init__(self, env):
super().__init__(env)
[docs]
def step(self, action):
obs, reward, terminated, truncated, info = self.env.step(action)
# Replace reward with success (-1.0 or 0.0)
reward = info["success"] - 1.0
return obs, reward, terminated, truncated, info