def __init__(self, *args, **kwargs): xml_path = os.path.split( os.path.realpath(__file__))[0] + '/models/silvia' + str( kwargs['legs']) + '.xml' MujocoEnv.__init__(self, xml_path, 5) utils.EzPickle.__init__(self) Serializable.__init__(self, *args, **kwargs)
def __init__(self, goal=(0, -1), arm_object_distance_cost_coeff=0, goal_object_distance_cost_coeff=1.0, ctrl_cost_coeff=0.1): """ goal (`list`): List of two elements denoting the x and y coordinates of the goal location. Either of the coordinate can also be a string 'any' to make the reward not to depend on the corresponding coordinate. arm_distance_coeff ('float'): Coefficient for the arm-to-object distance cost. goal_distance_coeff ('float'): Coefficient for the object-to-goal distance cost. """ utils.EzPickle.__init__(**locals()) self._goal_mask = [coordinate != 'any' for coordinate in goal] self._goal = np.array(goal)[self._goal_mask].astype(np.float32) self._arm_object_distance_cost_coeff = arm_object_distance_cost_coeff self._goal_object_distance_cost_coeff = goal_object_distance_cost_coeff self._ctrl_cost_coeff = ctrl_cost_coeff MujocoEnv.__init__(self, model_path=self.MODEL_PATH, frame_skip=5) self.model.stat.extent = 10
def __init__(self, **kwargs): self.MAPPING = {0: [0, 1], 1: [2, 3]} self.REST_POSE = np.array([0.0, 0.0, 0.0, 0.0]) #NEED TO DEFINE WITH ALEXIE self.LEGS_UP = np.array([0.0, 0.0, 0.0, 0.0]) #NEED TO DEFINE WITH ALEXIE self.COXA_LIMIT = (-1 / 3, 1 / 3) self.KNEE_LIMIT = (-1 / 2, 1 / 2) self.COXA_INDEX = [0, 2] self.KNEE_INDEX = [1, 3] self.legs = kwargs['legs'] self.act_dim = self.legs * 2 self.leg_indices = kwargs['leg_indices'] self.act_index, self.other_index = self.get_index() self.obs_dim = kwargs['observation_dim'] self.input_dim = kwargs['policy_output_dim'] self.move = self.REST_POSE.copy()[0:2] self.pos = self.REST_POSE.copy() xml_path = os.path.dirname( os.path.abspath(__file__) ) + '/envs/model/xmlfilename.xml' #NEED TO MODIFY XML FILE NAME MujocoEnv.__init__(self, xml_path, 5) #frame skip : 5, Initialize self utils.EzPickle.__init__(self)
def __init__(self: MujocoEnv, xml_path, ref_trajecs: RefTrajecs): '''@param: self: gym environment class extending the MimicEnv class @param: xml_path: path to the mujoco environment XML file @param: ref_trajecs: Instance of the ReferenceTrajectory''' self.refs = ref_trajecs # set simulation and control frequency self._sim_freq, self._frame_skip = self.get_sim_freq_and_frameskip() # keep the body in the air for testing purposes self._FLY = False or cfg.is_mod(cfg.MOD_FLY) # when we evaluate a model during or after the training, # we might want to weaken ET conditions or monitor and plot data self._EVAL_MODEL = False # control desired walking speed self.FOLLOW_DESIRED_SPEED_PROFILE = False # track individual reward components self.pos_rew, self.vel_rew, self.com_rew = 0, 0, 0 self.mean_epret_smoothed = 0 # track running mean of the return and use it for ET reward self.ep_rews = [] # initialize Mujoco Environment MujocoEnv.__init__(self, xml_path, self._frame_skip) # init EzPickle (think it is required to be able to save and load models) gym.utils.EzPickle.__init__(self) # make sure simulation and control run at the desired frequency self.model.opt.timestep = 1 / self._sim_freq self.control_freq = self._sim_freq / self._frame_skip # sync reference data with the control frequency self.refs.set_sampling_frequency(self.control_freq) # The motor torque ranges should always be specified in the config file # and overwrite the forcerange in the .MJCF file self.model.actuator_forcerange[:, :] = cfg.TORQUE_RANGES
def __init__(self, require_shadow=False): xml_path = 'half_cheetah(no_shadow).xml' if require_shadow: xml_path = "half_cheetah.xml" xml_path = os.path.join(os.path.dirname(__file__), "modified_mujoco_assets", xml_path) MujocoEnv.__init__(self, xml_path, 1) utils.EzPickle.__init__(self)
def __init__(self, goal_velocity=None): # self.set_task(self.sample_tasks(1)[0]) if goal_velocity: self.goal_velocity = goal_velocity else: self.set_task(self.sample_tasks(1)[0]) #1.0 MujocoEnv.__init__(self, 'half_cheetah.xml', 5) gym.utils.EzPickle.__init__(self)
def __init__(self, random_reset=True, ptsize=2): utils.EzPickle.__init__(self) MujocoEnv.__init__( self, os.path.join(os.path.abspath(os.path.dirname(__file__)), 'assets', 'point_pos_distractor.xml'), 2) self.random_reset = random_reset
def __init__(self): self.goal = np.ones((3,)) MujocoEnv.__init__(self, os.path.join(os.path.dirname(__file__), "assets", "pr2.xml"), 2) gym.utils.EzPickle.__init__(self) context = zmq.Context() self.socket = context.socket(zmq.REQ) self.socket.connect("tcp://localhost:5555") # Socket to talk to server print("Connecting to the client…") self.start()
def __init__(self): self.viewer = None self.work_path = Context.work_path self.world = Context.world self.step_num = 0 self.episode_num = 0 self.model_path = self._compile_model() MujocoEnv.__init__(self, self.model_path, frame_skip=Context.config['env.frame_skip'])
def __init__(self): self.mode_locations = np.array([[0.225, 0.225]], dtype=np.float32) self.noise_scale = 0.10 self.max_norm = 0.30 self.set_task(self.sample_tasks(1)[0]) asset_path = os.path.join( os.getcwd(), 'meta_policy_search/envs/mujoco_envs/assets/reacher_3link.xml') MujocoEnv.__init__(self, asset_path, 2) utils.EzPickle.__init__(self)
def __init__(self): np.random.seed(1337) self.NUM_TRAIN = 100 self.NUM_EVAL = 30 self.NUM_TASKS = self.NUM_TRAIN + self.NUM_EVAL self._tasks = np.random.uniform(0.0, 3.0, (self.NUM_TASKS, )) self.set_task(self._tasks[0]) MujocoEnv.__init__(self, 'half_cheetah.xml', 5) gym.utils.EzPickle.__init__(self)
def __init__(self): np.random.seed(1337) self.NUM_TRAIN = 150 self.NUM_EVAL = 30 self.NUM_TASKS = self.NUM_TRAIN + self.NUM_EVAL a = np.random.random(self.NUM_TASKS) * 2 * np.pi r = 3 * np.random.random(self.NUM_TASKS)**0.5 self._tasks = np.stack((r * np.cos(a), r * np.sin(a)), axis=-1) self.set_task(self._tasks[0]) MujocoEnv.__init__(self, 'ant.xml', 5) gym.utils.EzPickle.__init__(self)
def __init__(self): np.random.seed(1337) self.NUM_TRAIN = 100 self.NUM_EVAL = 30 self.NUM_TASKS = self.NUM_TRAIN + self.NUM_EVAL self._tasks = np.random.uniform(0., 2.0 * np.pi, size=(self.NUM_TASKS, )) self.set_task(self._tasks[0]) MujocoEnv.__init__(self, 'humanoid.xml', 5) gym.utils.EzPickle.__init__(self)
def __init__(self, env_type='default', reward_type='dense'): self.goal = np.array([1.0, 1.0]) self._use_simulator = True self._env_type = env_type self._reward_type = reward_type if env_type == 'default': model_path = self.MODEL_PATH_DEFAULT elif env_type == 'y': model_path = self.MODEL_PATH_Y elif env_type == 't': model_path = self.MODEL_PATH_T elif env_type == 'skewed_square': model_path = self.MODEL_PATH_DEFAULT MujocoEnv.__init__(self, model_path=model_path, frame_skip=5)
def __init__(self, action_repeat=1): """ Constructor for :class:`SpiderEnv`. :param action_repeat: Number of times action should be repeated in MuJoCo between each RL time step """ EzPickle.__init__(self) self._has_button_been_pressed_before = False MujocoEnv.__init__( self, str(Path("../../mujoco/spider.xml").resolve()), frame_skip=action_repeat, )
def __init__(self, **kwargs): self.MAPPING = {0: [0, 1], 1: [2, 3]} self.REST_POSE = np.array([-1/4, 1/8, 1/4, -1/8]) # NEED TO DEFINE WITH ALEXIE #0: RIGHT HIP, 1: RIGHT KNEE, 2: LEFT HIP, 3: LEFT KNEE # self.LEGS_UP = np.array([0.0, 0.0, 0.0, 0.0]) # NEED TO DEFINE WITH ALEXIE # self.RIGHT_HIP_LIMIT = (0, 1/2) # self.LEFT_HIP_LIMIT = (-1/2, 0) self.RIGHT_HIP_LIMIT = (-1/3, -1/6) # - self.LEFT_HIP_LIMIT = (1/6, 1/3) # + self.RIGHT_KNEE_LIMIT = (0, 1/4) # + self.LEFT_KNEE_LIMIT = (-1/4, 0) # - self.RIGHT_HIP_INDEX = 0 self.RIGHT_KNEE_INDEX = 1 self.LEFT_HIP_INDEX = 2 self.LEFT_KNEE_INDEX = 3 self.RIGHT_HIP_BL_INDEX = 4 self.RIGHT_KNEE_BL_INDEX = 5 self.LEFT_HIP_BL_INDEX = 6 self.LEFT_KNEE_BL_INDEX = 7 self.KNEE_INDEX = [1, 3] self.HIP_INDEX = [0, 2] self.len_Femur = 0.39152 self.len_Tibia = 0.39857 self.dist_btwn = 0.035 self.pos = self.REST_POSE.copy() self.reward = 0 self.numofmotor = 4 self.policy = kwargs['policy'] # xml_path = os.path.dirname( # os.path.abspath(__file__)) + '/envs/model/past_NABI-v0.xml' # NEED TO MODIFY XML FILE NAME xml_path = '/home/jin/project/rlnabi/PPO/envs/model/Nabi-v0.xml' # xml_path = '/home/jin/project/rlnabi/PPO/envs/model/Nabi-v1_jump.xml' frame_skip = 1 MujocoEnv.__init__(self, xml_path, frame_skip) # frame skip : 5, Initialize self utils.EzPickle.__init__(self)
def __init__(self): self.goal_radius = 4.0 self.noise_scale = 0.8 self.mode_locations = [] max_range = np.pi for i in range(1): ang = i * max_range / 3 - np.pi / 2 self.mode_locations.append([ self.goal_radius * np.sin(ang), self.goal_radius * np.cos(ang) ]) self.mode_locations = np.array(self.mode_locations) self.set_task(self.sample_tasks(1)[0]) asset_path = os.path.join( os.getcwd(), 'meta_policy_search/envs/mujoco_envs/assets/ant_target.xml') MujocoEnv.__init__(self, asset_path, 2) gym.utils.EzPickle.__init__(self)
def __init__(self, episode_len=499): # # 1 x 1 x 8 x 2 # self.valid_targets = np.array( # [[[ # [8.0, 0.0], # [0.0, 8.0], # [-8.0, 0.0], # [0.0, -8.0], # ]]] # ) self.timestep = 0.0 self.episode_len = episode_len # self.init_xy = init_pos.copy() xml_path = os.path.join(os.path.dirname(__file__), "assets", 'low_gear_ratio_ant.xml') # xml_path = os.path.join(os.path.dirname(__file__), "assets", 's_maze.xml') MujocoEnv.__init__(self, xml_path, 5) utils.EzPickle.__init__(self)
def __init__(self): a = np.sqrt(0.225**2 + 0.225**2) # regular hexagon self.mode_locations = np.array([ [a, 0], [a / 2, np.sqrt(3) * a / 2], [-a / 2, np.sqrt(3) * a / 2], [-a / 2, -np.sqrt(3) * a / 2], [a / 2, -np.sqrt(3) * a / 2], [-a, 0], ], dtype=np.float32) self.noise_scale = 0.1 self.max_norm = 0.30 self.set_task(self.sample_tasks(1)[0]) asset_path = os.path.join( os.getcwd(), 'meta_policy_search/envs/mujoco_envs/assets/reacher_3link.xml') MujocoEnv.__init__(self, asset_path, 2) utils.EzPickle.__init__(self)
def __init__(self, task='hfield', reset_task_every_episode=False, *args, **kwargs): self.reset_task_every_episode = reset_task_every_episode self.first = True self._action_bounds = None MujocoEnv.__init__(self, self.FILE, 1) self._action_bounds = self.action_space.low, self.action_space.high gym.utils.EzPickle.__init__(self) # hfield default configuration self.x_walls = np.array([250, 260, 261, 270, 280, 285]) self.height_walls = np.array([0.2, 0.2, 0.2, 0.2, 0.2, 0.2]) self.height = 0.8 self.width = 15 assert task in [ None, 'None', 'hfield', 'same', 'hill', 'gentle', 'steep', 'basin' ] self.task = task
def __init__(self, use_rel_pos_obs=False, terminate_near_target=False): self.terminate_near_target = terminate_near_target self.terminate_radius = 0.5 self.use_rel_pos_obs = use_rel_pos_obs # 1 x 1 x 8 x 2 self.valid_targets = np.array([[[ # [2.0, 0.0], # # [1.41, 1.41], # [0.0, 2.0], # # [-1.41, 1.41], # [-2.0, 0.0], # # [-1.41, -1.41], # [0.0, -2.0], # # [1.41, -1.41] [4.0, 0.0], [0.0, 4.0], [-4.0, 0.0], [0.0, -4.0], ]]]) xml_path = os.path.join(os.path.dirname(__file__), "assets", 'low_gear_ratio_ant.xml') MujocoEnv.__init__(self, xml_path, 5) utils.EzPickle.__init__(self)
def reset(self, *args, **kwargs): MujocoEnv.reset(self, *args, **kwargs) return self._get_obs()
def __init__(self, task=None): MetaEnv.__init__(self, task) MujocoEnv.__init__(self, 'ant.xml', 5) gym.utils.EzPickle.__init__(self)
def __init__(self): MujocoEnv.__init__(self, 'half_cheetah.xml', 5) gym.utils.EzPickle.__init__(self)
def __init__(self, goal_direction=None): self.goal_direction = goal_direction if goal_direction else 1.0 MujocoEnv.__init__(self, 'half_cheetah.xml', 5) gym.utils.EzPickle.__init__(self, goal_direction)
def __init__(self): MujocoEnv.__init__(self, 'swimmer.xml', 4) gym.utils.EzPickle.__init__(self)
def __init__(self, goal_direction=None): self.goal_direction = goal_direction if goal_direction else 1.0 MujocoEnv.__init__(self, "half_cheetah.xml", 5) EzPickle.__init__(self, goal_direction)
def __init__(self): self.set_task(self.sample_tasks(1)[0]) MujocoEnv.__init__(self, 'ant.xml', 5) gym.utils.EzPickle.__init__(self)
def __init__(self, goal_direction=None): MujocoEnv.__init__(self, 'ant.xml', 5) gym.utils.EzPickle.__init__(self)
def __init__(self): self.set_task(self.sample_tasks(1)[0]) MujocoEnv.__init__(self, 'walker2d.xml', 8) gym.utils.EzPickle.__init__(self)