updates on mp wrappers and some bugfixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
import os
|
||||
from abc import abstractmethod
|
||||
|
||||
|
||||
from gym import error, spaces
|
||||
@@ -142,18 +143,20 @@ class AlrMujocoEnv(gym.Env):
|
||||
# methods to override:
|
||||
# ----------------------------
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def active_obs(self):
|
||||
"""Returns boolean mask for each observation entry
|
||||
whether the observation is returned for the contextual case or not.
|
||||
This effectively allows to filter unwanted or unnecessary observations from the full step-based case.
|
||||
"""
|
||||
return np.ones(self.observation_space.shape, dtype=bool)
|
||||
|
||||
def _get_obs(self):
|
||||
"""Returns the observation.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def configure(self, *args, **kwargs):
|
||||
"""
|
||||
Helper method to set certain environment properties such as contexts in contextual environments since reset()
|
||||
doesn't take arguments. Should be called before reset().
|
||||
"""
|
||||
pass
|
||||
|
||||
def reset_model(self):
|
||||
"""
|
||||
Reset the robot degrees of freedom (qpos and qvel).
|
||||
|
||||
@@ -22,7 +22,7 @@ class ALRBallInACupEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||
self.j_min = np.array([-2.6, -1.985, -2.8, -0.9, -4.55, -1.5707, -2.7])
|
||||
self.j_max = np.array([2.6, 1.985, 2.8, 3.14159, 1.25, 1.5707, 2.7])
|
||||
|
||||
self.context = None
|
||||
self.context = context
|
||||
|
||||
utils.EzPickle.__init__(self)
|
||||
alr_mujoco_env.AlrMujocoEnv.__init__(self,
|
||||
@@ -45,7 +45,6 @@ class ALRBallInACupEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||
else:
|
||||
raise ValueError("Unknown reward type")
|
||||
self.reward_function = reward_function(self.sim_steps)
|
||||
self.configure(context)
|
||||
|
||||
@property
|
||||
def start_pos(self):
|
||||
@@ -69,10 +68,6 @@ class ALRBallInACupEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||
def current_vel(self):
|
||||
return self.sim.data.qvel[0:7].copy()
|
||||
|
||||
def configure(self, context):
|
||||
self.context = context
|
||||
self.reward_function.reset(context)
|
||||
|
||||
def reset_model(self):
|
||||
init_pos_all = self.init_qpos.copy()
|
||||
init_pos_robot = self._start_pos
|
||||
@@ -129,6 +124,16 @@ class ALRBallInACupEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||
[self._steps],
|
||||
])
|
||||
|
||||
# TODO
|
||||
@property
|
||||
def active_obs(self):
|
||||
return np.hstack([
|
||||
[False] * 7, # cos
|
||||
[False] * 7, # sin
|
||||
# [True] * 2, # x-y coordinates of target distance
|
||||
[False] # env steps
|
||||
])
|
||||
|
||||
# These functions are for the task with 3 joint actuations
|
||||
def extend_des_pos(self, des_pos):
|
||||
des_pos_full = self._start_pos.copy()
|
||||
|
||||
@@ -105,6 +105,7 @@ class ALRBeerpongEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||
def check_traj_in_joint_limits(self):
|
||||
return any(self.current_pos > self.j_max) or any(self.current_pos < self.j_min)
|
||||
|
||||
# TODO
|
||||
def _get_obs(self):
|
||||
theta = self.sim.data.qpos.flat[:7]
|
||||
return np.concatenate([
|
||||
@@ -114,6 +115,10 @@ class ALRBeerpongEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||
[self._steps],
|
||||
])
|
||||
|
||||
# TODO
|
||||
def active_obs(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user