mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-19 13:32:03 +00:00
fix advanced mujoco envs for windows path separation (#1220)
This commit is contained in:
committed by
Matthias Plappert
parent
803d84e5d5
commit
a488c2fe2f
@@ -1,7 +1,12 @@
|
|||||||
|
import os
|
||||||
from gym import utils
|
from gym import utils
|
||||||
from gym.envs.robotics import fetch_env
|
from gym.envs.robotics import fetch_env
|
||||||
|
|
||||||
|
|
||||||
|
# Ensure we get the path separator correct on windows
|
||||||
|
MODEL_XML_PATH = os.path.join('fetch', 'pick_and_place.xml')
|
||||||
|
|
||||||
|
|
||||||
class FetchPickAndPlaceEnv(fetch_env.FetchEnv, utils.EzPickle):
|
class FetchPickAndPlaceEnv(fetch_env.FetchEnv, utils.EzPickle):
|
||||||
def __init__(self, reward_type='sparse'):
|
def __init__(self, reward_type='sparse'):
|
||||||
initial_qpos = {
|
initial_qpos = {
|
||||||
@@ -11,7 +16,7 @@ class FetchPickAndPlaceEnv(fetch_env.FetchEnv, utils.EzPickle):
|
|||||||
'object0:joint': [1.25, 0.53, 0.4, 1., 0., 0., 0.],
|
'object0:joint': [1.25, 0.53, 0.4, 1., 0., 0., 0.],
|
||||||
}
|
}
|
||||||
fetch_env.FetchEnv.__init__(
|
fetch_env.FetchEnv.__init__(
|
||||||
self, 'fetch/pick_and_place.xml', has_object=True, block_gripper=False, n_substeps=20,
|
self, MODEL_XML_PATH, has_object=True, block_gripper=False, n_substeps=20,
|
||||||
gripper_extra_height=0.2, target_in_the_air=True, target_offset=0.0,
|
gripper_extra_height=0.2, target_in_the_air=True, target_offset=0.0,
|
||||||
obj_range=0.15, target_range=0.15, distance_threshold=0.05,
|
obj_range=0.15, target_range=0.15, distance_threshold=0.05,
|
||||||
initial_qpos=initial_qpos, reward_type=reward_type)
|
initial_qpos=initial_qpos, reward_type=reward_type)
|
||||||
|
@@ -1,7 +1,12 @@
|
|||||||
|
import os
|
||||||
from gym import utils
|
from gym import utils
|
||||||
from gym.envs.robotics import fetch_env
|
from gym.envs.robotics import fetch_env
|
||||||
|
|
||||||
|
|
||||||
|
# Ensure we get the path separator correct on windows
|
||||||
|
MODEL_XML_PATH = os.path.join('fetch', 'push.xml')
|
||||||
|
|
||||||
|
|
||||||
class FetchPushEnv(fetch_env.FetchEnv, utils.EzPickle):
|
class FetchPushEnv(fetch_env.FetchEnv, utils.EzPickle):
|
||||||
def __init__(self, reward_type='sparse'):
|
def __init__(self, reward_type='sparse'):
|
||||||
initial_qpos = {
|
initial_qpos = {
|
||||||
@@ -11,7 +16,7 @@ class FetchPushEnv(fetch_env.FetchEnv, utils.EzPickle):
|
|||||||
'object0:joint': [1.25, 0.53, 0.4, 1., 0., 0., 0.],
|
'object0:joint': [1.25, 0.53, 0.4, 1., 0., 0., 0.],
|
||||||
}
|
}
|
||||||
fetch_env.FetchEnv.__init__(
|
fetch_env.FetchEnv.__init__(
|
||||||
self, 'fetch/push.xml', has_object=True, block_gripper=True, n_substeps=20,
|
self, MODEL_XML_PATH, has_object=True, block_gripper=True, n_substeps=20,
|
||||||
gripper_extra_height=0.0, target_in_the_air=False, target_offset=0.0,
|
gripper_extra_height=0.0, target_in_the_air=False, target_offset=0.0,
|
||||||
obj_range=0.15, target_range=0.15, distance_threshold=0.05,
|
obj_range=0.15, target_range=0.15, distance_threshold=0.05,
|
||||||
initial_qpos=initial_qpos, reward_type=reward_type)
|
initial_qpos=initial_qpos, reward_type=reward_type)
|
||||||
|
@@ -1,7 +1,12 @@
|
|||||||
|
import os
|
||||||
from gym import utils
|
from gym import utils
|
||||||
from gym.envs.robotics import fetch_env
|
from gym.envs.robotics import fetch_env
|
||||||
|
|
||||||
|
|
||||||
|
# Ensure we get the path separator correct on windows
|
||||||
|
MODEL_XML_PATH = os.path.join('fetch', 'reach.xml')
|
||||||
|
|
||||||
|
|
||||||
class FetchReachEnv(fetch_env.FetchEnv, utils.EzPickle):
|
class FetchReachEnv(fetch_env.FetchEnv, utils.EzPickle):
|
||||||
def __init__(self, reward_type='sparse'):
|
def __init__(self, reward_type='sparse'):
|
||||||
initial_qpos = {
|
initial_qpos = {
|
||||||
@@ -10,7 +15,7 @@ class FetchReachEnv(fetch_env.FetchEnv, utils.EzPickle):
|
|||||||
'robot0:slide2': 0.0,
|
'robot0:slide2': 0.0,
|
||||||
}
|
}
|
||||||
fetch_env.FetchEnv.__init__(
|
fetch_env.FetchEnv.__init__(
|
||||||
self, 'fetch/reach.xml', has_object=False, block_gripper=True, n_substeps=20,
|
self, MODEL_XML_PATH, has_object=False, block_gripper=True, n_substeps=20,
|
||||||
gripper_extra_height=0.2, target_in_the_air=True, target_offset=0.0,
|
gripper_extra_height=0.2, target_in_the_air=True, target_offset=0.0,
|
||||||
obj_range=0.15, target_range=0.15, distance_threshold=0.05,
|
obj_range=0.15, target_range=0.15, distance_threshold=0.05,
|
||||||
initial_qpos=initial_qpos, reward_type=reward_type)
|
initial_qpos=initial_qpos, reward_type=reward_type)
|
||||||
|
@@ -1,9 +1,14 @@
|
|||||||
|
import os
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from gym import utils
|
from gym import utils
|
||||||
from gym.envs.robotics import fetch_env
|
from gym.envs.robotics import fetch_env
|
||||||
|
|
||||||
|
|
||||||
|
# Ensure we get the path separator correct on windows
|
||||||
|
MODEL_XML_PATH = os.path.join('fetch', 'slide.xml')
|
||||||
|
|
||||||
|
|
||||||
class FetchSlideEnv(fetch_env.FetchEnv, utils.EzPickle):
|
class FetchSlideEnv(fetch_env.FetchEnv, utils.EzPickle):
|
||||||
def __init__(self, reward_type='sparse'):
|
def __init__(self, reward_type='sparse'):
|
||||||
initial_qpos = {
|
initial_qpos = {
|
||||||
@@ -13,7 +18,7 @@ class FetchSlideEnv(fetch_env.FetchEnv, utils.EzPickle):
|
|||||||
'object0:joint': [1.7, 1.1, 0.4, 1., 0., 0., 0.],
|
'object0:joint': [1.7, 1.1, 0.4, 1., 0., 0., 0.],
|
||||||
}
|
}
|
||||||
fetch_env.FetchEnv.__init__(
|
fetch_env.FetchEnv.__init__(
|
||||||
self, 'fetch/slide.xml', has_object=True, block_gripper=True, n_substeps=20,
|
self, MODEL_XML_PATH, has_object=True, block_gripper=True, n_substeps=20,
|
||||||
gripper_extra_height=-0.02, target_in_the_air=False, target_offset=np.array([0.4, 0.0, 0.0]),
|
gripper_extra_height=-0.02, target_in_the_air=False, target_offset=np.array([0.4, 0.0, 0.0]),
|
||||||
obj_range=0.1, target_range=0.3, distance_threshold=0.05,
|
obj_range=0.1, target_range=0.3, distance_threshold=0.05,
|
||||||
initial_qpos=initial_qpos, reward_type=reward_type)
|
initial_qpos=initial_qpos, reward_type=reward_type)
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from gym import utils, error
|
from gym import utils, error
|
||||||
@@ -18,6 +19,12 @@ def quat_from_angle_and_axis(angle, axis):
|
|||||||
return quat
|
return quat
|
||||||
|
|
||||||
|
|
||||||
|
# Ensure we get the path separator correct on windows
|
||||||
|
MANIPULATE_BLOCK_XML = os.path.join('hand', 'manipulate_block.xml')
|
||||||
|
MANIPULATE_EGG_XML = os.path.join('hand', 'manipulate_egg.xml')
|
||||||
|
MANIPULATE_PEN_XML = os.path.join('hand', 'manipulate_pen.xml')
|
||||||
|
|
||||||
|
|
||||||
class ManipulateEnv(hand_env.HandEnv, utils.EzPickle):
|
class ManipulateEnv(hand_env.HandEnv, utils.EzPickle):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, model_path, target_position, target_rotation,
|
self, model_path, target_position, target_rotation,
|
||||||
@@ -267,7 +274,7 @@ class ManipulateEnv(hand_env.HandEnv, utils.EzPickle):
|
|||||||
class HandBlockEnv(ManipulateEnv):
|
class HandBlockEnv(ManipulateEnv):
|
||||||
def __init__(self, target_position='random', target_rotation='xyz', reward_type='sparse'):
|
def __init__(self, target_position='random', target_rotation='xyz', reward_type='sparse'):
|
||||||
super(HandBlockEnv, self).__init__(
|
super(HandBlockEnv, self).__init__(
|
||||||
model_path='hand/manipulate_block.xml', target_position=target_position,
|
model_path=MANIPULATE_BLOCK_XML, target_position=target_position,
|
||||||
target_rotation=target_rotation,
|
target_rotation=target_rotation,
|
||||||
target_position_range=np.array([(-0.04, 0.04), (-0.06, 0.02), (0.0, 0.06)]),
|
target_position_range=np.array([(-0.04, 0.04), (-0.06, 0.02), (0.0, 0.06)]),
|
||||||
reward_type=reward_type)
|
reward_type=reward_type)
|
||||||
@@ -276,7 +283,7 @@ class HandBlockEnv(ManipulateEnv):
|
|||||||
class HandEggEnv(ManipulateEnv):
|
class HandEggEnv(ManipulateEnv):
|
||||||
def __init__(self, target_position='random', target_rotation='xyz', reward_type='sparse'):
|
def __init__(self, target_position='random', target_rotation='xyz', reward_type='sparse'):
|
||||||
super(HandEggEnv, self).__init__(
|
super(HandEggEnv, self).__init__(
|
||||||
model_path='hand/manipulate_egg.xml', target_position=target_position,
|
model_path=MANIPULATE_EGG_XML, target_position=target_position,
|
||||||
target_rotation=target_rotation,
|
target_rotation=target_rotation,
|
||||||
target_position_range=np.array([(-0.04, 0.04), (-0.06, 0.02), (0.0, 0.06)]),
|
target_position_range=np.array([(-0.04, 0.04), (-0.06, 0.02), (0.0, 0.06)]),
|
||||||
reward_type=reward_type)
|
reward_type=reward_type)
|
||||||
@@ -285,7 +292,7 @@ class HandEggEnv(ManipulateEnv):
|
|||||||
class HandPenEnv(ManipulateEnv):
|
class HandPenEnv(ManipulateEnv):
|
||||||
def __init__(self, target_position='random', target_rotation='xyz', reward_type='sparse'):
|
def __init__(self, target_position='random', target_rotation='xyz', reward_type='sparse'):
|
||||||
super(HandPenEnv, self).__init__(
|
super(HandPenEnv, self).__init__(
|
||||||
model_path='hand/manipulate_pen.xml', target_position=target_position,
|
model_path=MANIPULATE_PEN_XML, target_position=target_position,
|
||||||
target_rotation=target_rotation,
|
target_rotation=target_rotation,
|
||||||
target_position_range=np.array([(-0.04, 0.04), (-0.06, 0.02), (0.0, 0.06)]),
|
target_position_range=np.array([(-0.04, 0.04), (-0.06, 0.02), (0.0, 0.06)]),
|
||||||
randomize_initial_rotation=False, reward_type=reward_type,
|
randomize_initial_rotation=False, reward_type=reward_type,
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from gym import utils
|
from gym import utils
|
||||||
@@ -42,6 +43,10 @@ DEFAULT_INITIAL_QPOS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Ensure we get the path separator correct on windows
|
||||||
|
MODEL_XML_PATH = os.path.join('hand', 'reach.xml')
|
||||||
|
|
||||||
|
|
||||||
def goal_distance(goal_a, goal_b):
|
def goal_distance(goal_a, goal_b):
|
||||||
assert goal_a.shape == goal_b.shape
|
assert goal_a.shape == goal_b.shape
|
||||||
return np.linalg.norm(goal_a - goal_b, axis=-1)
|
return np.linalg.norm(goal_a - goal_b, axis=-1)
|
||||||
@@ -56,7 +61,7 @@ class HandReachEnv(hand_env.HandEnv, utils.EzPickle):
|
|||||||
self.reward_type = reward_type
|
self.reward_type = reward_type
|
||||||
|
|
||||||
hand_env.HandEnv.__init__(
|
hand_env.HandEnv.__init__(
|
||||||
self, 'hand/reach.xml', n_substeps=n_substeps, initial_qpos=initial_qpos,
|
self, MODEL_XML_PATH, n_substeps=n_substeps, initial_qpos=initial_qpos,
|
||||||
relative_control=relative_control)
|
relative_control=relative_control)
|
||||||
utils.EzPickle.__init__(self)
|
utils.EzPickle.__init__(self)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user