Skip to content

Commit

Permalink
Update GazeboEnv to be compatible with the new OpenAI Gym release
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Sep 16, 2019
1 parent 99d511e commit 97661ef
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions gym_ignition/base/gazebo_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,21 @@ def __init__(self,
# Seed the environment
self.seed()

@property
def unwrapped(self):
# The task is not a complete gym.Env environment since task objects implement
# the Task interface.
# This wrapper implements the step method using Ignition Gazebo. For this reason,
# the unwrapped environment is the gym.Env interface provided by this wrapper.
return self
def __getattr__(self, name):
# We need to override this method because gym.Wrapper has a custom implementation
# that forwards all the asked attributes to the wrapped class.
# Due to this reason, regular wrappers cannot have new public methods and
# attributes. This is a workaround that requires specifying all the new ones in
# the list below.
#
# This fix is needed after https://github.com/openai/gym/issues/1554

exposed_public_attributes = ["gazebo"]

if name in exposed_public_attributes:
return self.__getattribute__(name)
else:
return getattr(self.env, name)

# ==========
# PROPERTIES
Expand Down

0 comments on commit 97661ef

Please sign in to comment.