Python gym.envs.mujoco.mujoco_env.MujocoEnv() Examples
The following are 30
code examples of gym.envs.mujoco.mujoco_env.MujocoEnv().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gym.envs.mujoco.mujoco_env
, or try the search function
.
Example #1
Source File: reacher_env.py From me-trpo with MIT License | 6 votes |
def __init__(self): utils.EzPickle.__init__(self) mujoco_env.MujocoEnv.__init__(self, 'reacher.xml', 2) # def _step(self, a): # # x = self._get_obs()[None] # # assert np.allclose(self.get_body_com("fingertip")[:2], get_fingertips(x)),\ # # str(self.get_body_com("fingertip")) + " "+ str(get_fingertips(x)) # vec = self.get_body_com("fingertip")-self.get_body_com("target") # reward_dist = - np.linalg.norm(vec[:2]) # reward_ctrl = - np.square(a).sum()*0.01 # reward = reward_dist + reward_ctrl # self.do_simulation(a, self.frame_skip) # ob = self._get_obs() # done = False # return ob, reward, done, dict(reward_dist=reward_dist, reward_ctrl=reward_ctrl)
Example #2
Source File: centipede_env.py From neural_graph_evolution with MIT License | 6 votes |
def __init__(self, CentipedeLegNum=4, is_crippled=False): # get the path of the environments if is_crippled: xml_name = 'CpCentipede' + self.get_env_num_str(CentipedeLegNum) + \ '.xml' else: xml_name = 'Centipede' + self.get_env_num_str(CentipedeLegNum) + \ '.xml' xml_path = os.path.join(init_path.get_base_dir(), 'environments', 'assets', xml_name) xml_path = str(os.path.abspath(xml_path)) self.num_body = int(np.ceil(CentipedeLegNum / 2.0)) self._control_cost_coeff = .5 * 4 / CentipedeLegNum self._contact_cost_coeff = 0.5 * 1e-3 * 4 / CentipedeLegNum self.torso_geom_id = 1 + np.array(range(self.num_body)) * 5 # make sure the centipede is not born to be end of episode self.body_qpos_id = 6 + 6 + np.array(range(self.num_body)) * 6 self.body_qpos_id[-1] = 5 mujoco_env.MujocoEnv.__init__(self, xml_path, 5) utils.EzPickle.__init__(self)
Example #3
Source File: snake_env.py From neural_graph_evolution with MIT License | 6 votes |
def __init__(self, pod_number=3, is_crippled=False): # get the path of the environments if is_crippled: xml_name = 'CrippledSnake' + self.get_env_num_str(pod_number) + \ '.xml' else: xml_name = 'Snake' + self.get_env_num_str(pod_number) + '.xml' xml_path = os.path.join(os.path.join(init_path.get_base_dir(), 'environments', 'assets', xml_name)) xml_path = str(os.path.abspath(xml_path)) self.num_body = pod_number self._direction = 0 self.ctrl_cost_coeff = 0.0001 / pod_number * 3 mujoco_env.MujocoEnv.__init__(self, xml_path, 4) utils.EzPickle.__init__(self)
Example #4
Source File: reacher_env.py From neural_graph_evolution with MIT License | 6 votes |
def __init__(self, pod_number=2): # get the path of the environments xml_name = 'Reacher' + self.get_env_num_str(pod_number) + '.xml' xml_path = os.path.join(os.path.join(init_path.get_base_dir(), 'environments', 'assets', xml_name)) xml_path = str(os.path.abspath(xml_path)) # the environment coeff self.num_body = pod_number + 1 self._task_indicator = -1.0 self._ctrl_coeff = 2.0 / (self.num_body / 2 + 1) # norm the max penalty to be 1, max norm is self.num_body * 0.1 * 2 self._dist_coeff = 2.0 / self.num_body mujoco_env.MujocoEnv.__init__(self, xml_path, 2) utils.EzPickle.__init__(self)
Example #5
Source File: point_maze_env.py From imitation with MIT License | 6 votes |
def __init__( self, direction=1, maze_length=0.6, sparse_reward=False, no_reward=False, include_vel=False, episode_length=100, ): utils.EzPickle.__init__(self) self.sparse_reward = sparse_reward self.no_reward = no_reward self.include_vel = include_vel self.max_episode_length = episode_length self.direction = direction self.length = maze_length self.episode_length = 0 model = point_mass_maze(direction=self.direction, length=self.length) with model.asfile() as f: mujoco_env.MujocoEnv.__init__(self, f.name, 5)
Example #6
Source File: swimmer_v3.py From DQN-DDPG_Stock_Trading with MIT License | 6 votes |
def __init__(self, xml_file='swimmer.xml', forward_reward_weight=1.0, ctrl_cost_weight=1e-4, reset_noise_scale=0.1, exclude_current_positions_from_observation=True): utils.EzPickle.__init__(**locals()) self._forward_reward_weight = forward_reward_weight self._ctrl_cost_weight = ctrl_cost_weight self._reset_noise_scale = reset_noise_scale self._exclude_current_positions_from_observation = ( exclude_current_positions_from_observation) mujoco_env.MujocoEnv.__init__(self, xml_file, 4)
Example #7
Source File: visual_pointmass.py From inverse_rl with MIT License | 6 votes |
def __init__(self, direction=1, maze_length=0.6, sparse_reward=False, no_reward=False, episode_length=100, grayscale=True, width=64, height=64): utils.EzPickle.__init__(self) self.sparse_reward = sparse_reward self.no_reward = no_reward self.max_episode_length = episode_length self.direction = direction self.length = maze_length self.width = width self.height = height self.grayscale=grayscale self.episode_length = 0 model = point_mass_maze(direction=self.direction, length=self.length, borders=False) with model.asfile() as f: mujoco_env.MujocoEnv.__init__(self, f.name, 5) if self.grayscale: self.observation_space = Box(0, 1, shape=(width, height)) else: self.observation_space = Box(0, 1, shape=(width, height, 3))
Example #8
Source File: reacher.py From rl_swiss with MIT License | 5 votes |
def __init__(self): utils.EzPickle.__init__(self) mujoco_env.MujocoEnv.__init__(self, 'reacher.xml', 2)
Example #9
Source File: walker2d.py From DQN-DDPG_Stock_Trading with MIT License | 5 votes |
def __init__(self): mujoco_env.MujocoEnv.__init__(self, "walker2d.xml", 4) utils.EzPickle.__init__(self)
Example #10
Source File: ant.py From DQN-DDPG_Stock_Trading with MIT License | 5 votes |
def __init__(self): mujoco_env.MujocoEnv.__init__(self, 'ant.xml', 5) utils.EzPickle.__init__(self)
Example #11
Source File: humanoidstandup.py From DQN-DDPG_Stock_Trading with MIT License | 5 votes |
def __init__(self): mujoco_env.MujocoEnv.__init__(self, 'humanoidstandup.xml', 5) utils.EzPickle.__init__(self)
Example #12
Source File: half_cheetah.py From DQN-DDPG_Stock_Trading with MIT License | 5 votes |
def __init__(self): mujoco_env.MujocoEnv.__init__(self, 'half_cheetah.xml', 5) utils.EzPickle.__init__(self)
Example #13
Source File: inverted_double_pendulum.py From DQN-DDPG_Stock_Trading with MIT License | 5 votes |
def __init__(self): mujoco_env.MujocoEnv.__init__(self, 'inverted_double_pendulum.xml', 5) utils.EzPickle.__init__(self)
Example #14
Source File: pusher.py From DQN-DDPG_Stock_Trading with MIT License | 5 votes |
def __init__(self): utils.EzPickle.__init__(self) mujoco_env.MujocoEnv.__init__(self, 'pusher.xml', 5)
Example #15
Source File: multi_ant.py From multiagent-gail with MIT License | 5 votes |
def setup(self): self.seed() self.gen_xml(out_file=self.out_file_path, og_file=self.base_file_path) mujoco_env.MujocoEnv.__init__(self, self.out_file_path, 5) self.legs = [AntLeg(self.model, i, self.n_legs, pos_noise=self.pos_noise, vel_noise=self.vel_noise, force_noise=self.force_noise) for i in range(self.n_legs)]
Example #16
Source File: multi_ant.py From multiagent-gail with MIT License | 5 votes |
def __init__(self, n_legs=4, ts=0.02, integrator='RK4', leg_length=0.282, out_file="multi_ant.xml", base_file="ant_og.xml", reward_mech='local', pos_noise=1e-3, vel_noise=1e-3, force_noise=1e-3 ): EzPickle.__init__(self, n_legs, ts, integrator, leg_length, out_file, base_file, reward_mech, pos_noise, vel_noise, force_noise) self.n_legs = n_legs self.ts = ts self.integrator = integrator self.leg_length = leg_length self.out_file = out_file self.base_file = base_file self._reward_mech = reward_mech self.pos_noise = pos_noise self.vel_noise = vel_noise self.force_noise = force_noise self.legs = None self.out_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), self.out_file) self.base_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), self.base_file) self.gen_xml(out_file=self.out_file_path, og_file=self.base_file_path) mujoco_env.MujocoEnv.__init__(self, self.out_file_path, 5) self.legs = [AntLeg(self.model, i, n_legs, pos_noise=pos_noise, vel_noise=vel_noise, force_noise=force_noise) for i in range(self.n_legs)]
Example #17
Source File: walker2d.py From multiagent-gail with MIT License | 5 votes |
def __init__(self, target_vel): self.target_vel = target_vel mujoco_env.MujocoEnv.__init__(self, "walker2d.xml", 4) utils.EzPickle.__init__(self)
Example #18
Source File: reacher_7dof_env.py From rl_swiss with MIT License | 5 votes |
def __init__(self, distance_metric_order=None, goal_dim_weights=None): self._desired_xyz = np.zeros(3) Serializable.quick_init(self, locals()) MultitaskEnv.__init__( self, distance_metric_order=distance_metric_order, goal_dim_weights=goal_dim_weights, ) mujoco_env.MujocoEnv.__init__( self, get_asset_xml('reacher_7dof.xml'), 5, ) self.observation_space = Box( np.array([ -2.28, -0.52, -1.4, -2.32, -1.5, -1.094, -1.5, # joint -3, -3, -3, -3, -3, -3, -3, # velocity -0.75, -1.25, -0.2, # EE xyz ]), np.array([ 1.71, 1.39, 1.7, 0, 1.5, 0, 1.5, # joints 3, 3, 3, 3, 3, 3, 3, # velocity 0.75, 0.25, 0.6, # EE xyz ]) )
Example #19
Source File: meta_ant.py From rl_swiss with MIT License | 5 votes |
def __init__(self, full_xml_path, meta_params): utils.EzPickle.__init__(self) mujoco_env.MujocoEnv.__init__(self, full_xml_path, 2) self.env_meta_params = meta_params
Example #20
Source File: reacher.py From rl_swiss with MIT License | 5 votes |
def __init__(self, full_xml_path, meta_params): utils.EzPickle.__init__(self) mujoco_env.MujocoEnv.__init__(self, full_xml_path, 2) self.env_meta_params = meta_params
Example #21
Source File: hopper.py From rl_swiss with MIT License | 5 votes |
def __init__(self, full_xml_path, meta_params): mujoco_env.MujocoEnv.__init__(self, full_xml_path, 2) utils.EzPickle.__init__(self) self.env_meta_params = meta_params
Example #22
Source File: multi_ant.py From MADRL with MIT License | 5 votes |
def setup(self): self.seed() self.gen_xml(out_file=self.out_file_path, og_file=self.base_file_path) mujoco_env.MujocoEnv.__init__(self, self.out_file_path, 5) self.legs = [AntLeg(self.model, i, self.n_legs, pos_noise=self.pos_noise, vel_noise=self.vel_noise, force_noise=self.force_noise) for i in range(self.n_legs)]
Example #23
Source File: hopper.py From rl_swiss with MIT License | 5 votes |
def __init__(self): mujoco_env.MujocoEnv.__init__(self, 'hopper.xml', 4) utils.EzPickle.__init__(self)
Example #24
Source File: state_matching_pusher_env_no_obj.py From rl_swiss with MIT License | 5 votes |
def __init__(self, obs_with_time=True, episode_len=500): self.timestep = 0.0 self.episode_len = episode_len self.obs_with_time = obs_with_time utils.EzPickle.__init__(self) mujoco_env.MujocoEnv.__init__( self, os.path.join(os.path.dirname(__file__), "assets", 'state_matching_pusher_no_obj.xml'), 5 )
Example #25
Source File: state_matching_pusher_env.py From rl_swiss with MIT License | 5 votes |
def __init__(self, obs_with_time=True, episode_len=200): self.timestep = 0.0 self.episode_len = episode_len self.obs_with_time = obs_with_time utils.EzPickle.__init__(self) mujoco_env.MujocoEnv.__init__( self, os.path.join(os.path.dirname(__file__), "assets", 'state_matching_pusher.xml'), 5 )
Example #26
Source File: halfcheetah_rand_vel.py From rl_swiss with MIT License | 5 votes |
def __init__(self): self.target_velocity = 0.0 mujoco_env.MujocoEnv.__init__(self, 'half_cheetah.xml', 5) utils.EzPickle.__init__(self)
Example #27
Source File: half_cheetah.py From rl_swiss with MIT License | 5 votes |
def __init__(self): mujoco_env.MujocoEnv.__init__(self, 'half_cheetah.xml', 5) utils.EzPickle.__init__(self)
Example #28
Source File: mujoco_env.py From rl_swiss with MIT License | 5 votes |
def __init__( self, model_path, frame_skip=1, model_path_is_local=True, automatically_set_obs_and_action_space=False, ): if model_path_is_local: model_path = get_asset_xml(model_path) if automatically_set_obs_and_action_space: mujoco_env.MujocoEnv.__init__(self, model_path, frame_skip) else: """ Code below is copy/pasted from MujocoEnv's __init__ function. """ if model_path.startswith("/"): fullpath = model_path else: fullpath = os.path.join(os.path.dirname(__file__), "assets", model_path) if not path.exists(fullpath): raise IOError("File %s does not exist" % fullpath) self.frame_skip = frame_skip self.model = mujoco_py.MjModel(fullpath) self.data = self.model.data self.viewer = None self.metadata = { 'render.modes': ['human', 'rgb_array'], 'video.frames_per_second': int(np.round(1.0 / self.dt)) } self.init_qpos = self.model.data.qpos.ravel().copy() self.init_qvel = self.model.data.qvel.ravel().copy() self._seed()
Example #29
Source File: base_inverted_pendulum.py From rl_swiss with MIT License | 5 votes |
def __init__(self, full_xml_path): utils.EzPickle.__init__(self) mujoco_env.MujocoEnv.__init__(self, full_xml_path, 2)
Example #30
Source File: walker_env.py From me-trpo with MIT License | 5 votes |
def __init__(self): mujoco_env.MujocoEnv.__init__(self, "walker2d.xml", 4) utils.EzPickle.__init__(self)