From 640f3b2d909656325a213e1a24592bbedf3c922c Mon Sep 17 00:00:00 2001 From: Onur Date: Tue, 3 May 2022 21:34:39 +0200 Subject: [PATCH] fix action space bugs for bp --- alr_envs/alr/mujoco/beerpong/new_mp_wrapper.py | 4 ++-- alr_envs/mp/episodic_wrapper.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/alr_envs/alr/mujoco/beerpong/new_mp_wrapper.py b/alr_envs/alr/mujoco/beerpong/new_mp_wrapper.py index 9cd6374..267e76e 100644 --- a/alr_envs/alr/mujoco/beerpong/new_mp_wrapper.py +++ b/alr_envs/alr/mujoco/beerpong/new_mp_wrapper.py @@ -38,7 +38,7 @@ class NewMPWrapper(EpisodicWrapper): min_action_bounds, max_action_bounds = self.mp.get_param_bounds() min_action_bounds = np.concatenate((min_action_bounds.numpy(), [self.env.action_space.low[-1]])) max_action_bounds = np.concatenate((max_action_bounds.numpy(), [self.env.action_space.high[-1]])) - self.mp_action_space = gym.spaces.Box(low=min_action_bounds, high=max_action_bounds, dtype=np.float32) - return self.mp_action_space + self.action_space = gym.spaces.Box(low=min_action_bounds, high=max_action_bounds, dtype=np.float32) + return self.action_space else: return super(NewMPWrapper, self).set_action_space() diff --git a/alr_envs/mp/episodic_wrapper.py b/alr_envs/mp/episodic_wrapper.py index ef0723e..092f1bc 100644 --- a/alr_envs/mp/episodic_wrapper.py +++ b/alr_envs/mp/episodic_wrapper.py @@ -70,7 +70,7 @@ class EpisodicWrapper(gym.Env, ABC): ignore_indices = int(self.mp.learn_tau) + int(self.mp.learn_delay) scaled_mp_params = action.copy() scaled_mp_params[ignore_indices:] *= self.weight_scale - self.mp.set_params(scaled_mp_params) + self.mp.set_params(np.clip(scaled_mp_params, self.mp_action_space.low, self.mp_action_space.high)) self.mp.set_boundary_conditions(bc_time=self.time_steps[:1], bc_pos=self.current_pos, bc_vel=self.current_vel) traj_dict = self.mp.get_mp_trajs(get_pos = True, get_vel = True) trajectory_tensor, velocity_tensor = traj_dict['pos'], traj_dict['vel']