diff --git a/alr_envs/__init__.py b/alr_envs/__init__.py index 5664d7c..e43e3b1 100644 --- a/alr_envs/__init__.py +++ b/alr_envs/__init__.py @@ -1,946 +1,15 @@ -from gym.envs.registration import register -from gym.wrappers import FlattenObservation - -from alr_envs import classic_control, dmc, open_ai, meta - -from alr_envs.utils.make_env_helpers import make_dmp_env -from alr_envs.utils.make_env_helpers import make_detpmp_env -from alr_envs.utils.make_env_helpers import make -from alr_envs.utils.make_env_helpers import make_rank +from alr_envs import dmc, meta, open_ai +from alr_envs.utils.make_env_helpers import make, make_detpmp_env, make_dmp_env, make_rank +from alr_envs.utils import make_dmc # Convenience function for all MP environments -ALL_MOTION_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "DetPMP": []} -ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "DetPMP": []} -ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "DetPMP": []} -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "DetPMP": []} -ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "DetPMP": []} +from .alr import ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS +from .dmc import ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS +from .meta import ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS +from .open_ai import ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS -# Mujoco - -## Reacher -register( - id='ALRReacher-v0', - entry_point='alr_envs.mujoco:ALRReacherEnv', - max_episode_steps=200, - kwargs={ - "steps_before_reward": 0, - "n_links": 5, - "balance": False, - } -) - -register( - id='ALRReacherSparse-v0', - entry_point='alr_envs.mujoco:ALRReacherEnv', - max_episode_steps=200, - kwargs={ - "steps_before_reward": 200, - "n_links": 5, - "balance": False, - } -) - -register( - id='ALRReacherSparseBalanced-v0', - entry_point='alr_envs.mujoco:ALRReacherEnv', - max_episode_steps=200, - kwargs={ - "steps_before_reward": 200, - "n_links": 5, - "balance": True, - } -) - -register( - id='ALRLongReacher-v0', - entry_point='alr_envs.mujoco:ALRReacherEnv', - max_episode_steps=200, - kwargs={ - "steps_before_reward": 0, - "n_links": 7, - "balance": False, - } -) - -register( - id='ALRLongReacherSparse-v0', - entry_point='alr_envs.mujoco:ALRReacherEnv', - max_episode_steps=200, - kwargs={ - "steps_before_reward": 200, - "n_links": 7, - "balance": False, - } -) - -register( - id='ALRLongReacherSparseBalanced-v0', - entry_point='alr_envs.mujoco:ALRReacherEnv', - max_episode_steps=200, - kwargs={ - "steps_before_reward": 200, - "n_links": 7, - "balance": True, - } -) - -## Balancing Reacher - -register( - id='Balancing-v0', - entry_point='alr_envs.mujoco:BalancingEnv', - max_episode_steps=200, - kwargs={ - "n_links": 5, - } -) - -# Classic control - -## Simple Reacher -register( - id='SimpleReacher-v0', - entry_point='alr_envs.classic_control:SimpleReacherEnv', - max_episode_steps=200, - kwargs={ - "n_links": 2, - } -) - -register( - id='SimpleReacher-v1', - entry_point='alr_envs.classic_control:SimpleReacherEnv', - max_episode_steps=200, - kwargs={ - "n_links": 2, - "random_start": False - } -) - -register( - id='LongSimpleReacher-v0', - entry_point='alr_envs.classic_control:SimpleReacherEnv', - max_episode_steps=200, - kwargs={ - "n_links": 5, - } -) - -register( - id='LongSimpleReacher-v1', - entry_point='alr_envs.classic_control:SimpleReacherEnv', - max_episode_steps=200, - kwargs={ - "n_links": 5, - "random_start": False - } -) - -## Viapoint Reacher - -register( - id='ViaPointReacher-v0', - entry_point='alr_envs.classic_control:ViaPointReacher', - max_episode_steps=200, - kwargs={ - "n_links": 5, - "allow_self_collision": False, - "collision_penalty": 1000 - } -) - -## Hole Reacher -register( - id='HoleReacher-v0', - entry_point='alr_envs.classic_control:HoleReacherEnv', - max_episode_steps=200, - kwargs={ - "n_links": 5, - "random_start": True, - "allow_self_collision": False, - "allow_wall_collision": False, - "hole_width": None, - "hole_depth": 1, - "hole_x": None, - "collision_penalty": 100, - } -) - -register( - id='HoleReacher-v1', - entry_point='alr_envs.classic_control:HoleReacherEnv', - max_episode_steps=200, - kwargs={ - "n_links": 5, - "random_start": False, - "allow_self_collision": False, - "allow_wall_collision": False, - "hole_width": 0.25, - "hole_depth": 1, - "hole_x": None, - "collision_penalty": 100, - } -) - -register( - id='HoleReacher-v2', - entry_point='alr_envs.classic_control:HoleReacherEnv', - max_episode_steps=200, - kwargs={ - "n_links": 5, - "random_start": False, - "allow_self_collision": False, - "allow_wall_collision": False, - "hole_width": 0.25, - "hole_depth": 1, - "hole_x": 2, - "collision_penalty": 100, - } -) - -# Motion Primitive Environments - -## Simple Reacher -versions = ["SimpleReacher-v0", "SimpleReacher-v1", "LongSimpleReacher-v0", "LongSimpleReacher-v1"] -for v in versions: - name = v.split("-") - env_id = f'{name[0]}DMP-{name[1]}' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"alr_envs:{v}", - "wrappers": [classic_control.simple_reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 2 if "long" not in v.lower() else 5, - "num_basis": 5, - "duration": 20, - "alpha_phase": 2, - "learn_goal": True, - "policy_type": "velocity", - "weights_scale": 50, - } - } - ) - ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(env_id) - - env_id = f'{name[0]}DetPMP-{name[1]}' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"alr_envs:{v}", - "wrappers": [classic_control.simple_reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 2 if "long" not in v.lower() else 5, - "num_basis": 5, - "duration": 20, - "width": 0.025, - "policy_type": "velocity", - "weights_scale": 0.2, - "zero_start": True - } - } - ) - ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(env_id) - -register( - id='ViaPointReacherDMP-v0', - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": "alr_envs:ViaPointReacher-v0", - "wrappers": [classic_control.viapoint_reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 5, - "num_basis": 5, - "duration": 2, - "learn_goal": True, - "alpha_phase": 2, - "policy_type": "velocity", - "weights_scale": 50, - } - } -) -ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("ViaPointReacherDMP-v0") - -register( - id='ViaPointReacherDetPMP-v0', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": "alr_envs:ViaPointReacher-v0", - "wrappers": [classic_control.viapoint_reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 5, - "num_basis": 5, - "duration": 2, - "width": 0.025, - "policy_type": "velocity", - "weights_scale": 0.2, - "zero_start": True - } - } -) -ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("ViaPointReacherDetPMP-v0") - -## Hole Reacher -versions = ["v0", "v1", "v2"] -for v in versions: - env_id = f'HoleReacherDMP-{v}' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"alr_envs:HoleReacher-{v}", - "wrappers": [classic_control.hole_reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 5, - "num_basis": 5, - "duration": 2, - "learn_goal": True, - "alpha_phase": 2, - "bandwidth_factor": 2, - "policy_type": "velocity", - "weights_scale": 50, - "goal_scale": 0.1 - } - } - ) - ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(env_id) - - env_id = f'HoleReacherDetPMP-{v}' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": f"alr_envs:HoleReacher-{v}", - "wrappers": [classic_control.hole_reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 5, - "num_basis": 5, - "duration": 2, - "width": 0.025, - "policy_type": "velocity", - "weights_scale": 0.2, - "zero_start": True - } - } - ) - ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(env_id) - -## Deep Mind Control Suite (DMC) -### Suite - -register( - id=f'dmc_ball_in_cup-catch_dmp-v0', - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"ball_in_cup-catch", - "time_limit": 20, - "episode_length": 1000, - "wrappers": [dmc.suite.ball_in_cup.MPWrapper], - "mp_kwargs": { - "num_dof": 2, - "num_basis": 5, - "duration": 20, - "learn_goal": True, - "alpha_phase": 2, - "bandwidth_factor": 2, - "policy_type": "motor", - "goal_scale": 0.1, - "policy_kwargs": { - "p_gains": 50, - "d_gains": 1 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("dmc_ball_in_cup-catch_dmp-v0") - -register( - id=f'dmc_ball_in_cup-catch_detpmp-v0', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": f"ball_in_cup-catch", - "time_limit": 20, - "episode_length": 1000, - "wrappers": [dmc.suite.ball_in_cup.MPWrapper], - "mp_kwargs": { - "num_dof": 2, - "num_basis": 5, - "duration": 20, - "width": 0.025, - "policy_type": "motor", - "zero_start": True, - "policy_kwargs": { - "p_gains": 50, - "d_gains": 1 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("dmc_ball_in_cup-catch_detpmp-v0") - -register( - id=f'dmc_reacher-easy_dmp-v0', - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"reacher-easy", - "time_limit": 20, - "episode_length": 1000, - "wrappers": [dmc.suite.reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 2, - "num_basis": 5, - "duration": 20, - "learn_goal": True, - "alpha_phase": 2, - "bandwidth_factor": 2, - "policy_type": "motor", - "weights_scale": 50, - "goal_scale": 0.1, - "policy_kwargs": { - "p_gains": 50, - "d_gains": 1 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("dmc_reacher-easy_dmp-v0") - -register( - id=f'dmc_reacher-easy_detpmp-v0', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": f"reacher-easy", - "time_limit": 20, - "episode_length": 1000, - "wrappers": [dmc.suite.reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 2, - "num_basis": 5, - "duration": 20, - "width": 0.025, - "policy_type": "motor", - "weights_scale": 0.2, - "zero_start": True, - "policy_kwargs": { - "p_gains": 50, - "d_gains": 1 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("dmc_reacher-easy_detpmp-v0") - -register( - id=f'dmc_reacher-hard_dmp-v0', - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"reacher-hard", - "time_limit": 20, - "episode_length": 1000, - "wrappers": [dmc.suite.reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 2, - "num_basis": 5, - "duration": 20, - "learn_goal": True, - "alpha_phase": 2, - "bandwidth_factor": 2, - "policy_type": "motor", - "weights_scale": 50, - "goal_scale": 0.1, - "policy_kwargs": { - "p_gains": 50, - "d_gains": 1 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("dmc_reacher-hard_dmp-v0") - -register( - id=f'dmc_reacher-hard_detpmp-v0', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": f"reacher-hard", - "time_limit": 20, - "episode_length": 1000, - "wrappers": [dmc.suite.reacher.MPWrapper], - "mp_kwargs": { - "num_dof": 2, - "num_basis": 5, - "duration": 20, - "width": 0.025, - "policy_type": "motor", - "weights_scale": 0.2, - "zero_start": True, - "policy_kwargs": { - "p_gains": 50, - "d_gains": 1 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("dmc_reacher-hard_detpmp-v0") - -dmc_cartpole_tasks = ["balance", "balance_sparse", "swingup", "swingup_sparse"] - -for task in dmc_cartpole_tasks: - env_id = f'dmc_cartpole-{task}_dmp-v0' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"cartpole-{task}", - # "time_limit": 1, - "camera_id": 0, - "episode_length": 1000, - "wrappers": [dmc.suite.cartpole.MPWrapper], - "mp_kwargs": { - "num_dof": 1, - "num_basis": 5, - "duration": 10, - "learn_goal": True, - "alpha_phase": 2, - "bandwidth_factor": 2, - "policy_type": "motor", - "weights_scale": 50, - "goal_scale": 0.1, - "policy_kwargs": { - "p_gains": 10, - "d_gains": 10 - } - } - } - ) - ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(env_id) - - env_id = f'dmc_cartpole-{task}_detpmp-v0' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": f"cartpole-{task}", - # "time_limit": 1, - "camera_id": 0, - "episode_length": 1000, - "wrappers": [dmc.suite.cartpole.MPWrapper], - "mp_kwargs": { - "num_dof": 1, - "num_basis": 5, - "duration": 10, - "width": 0.025, - "policy_type": "motor", - "weights_scale": 0.2, - "zero_start": True, - "policy_kwargs": { - "p_gains": 10, - "d_gains": 10 - } - } - } - ) - ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(env_id) - -env_id = f'dmc_cartpole-two_poles_dmp-v0' -register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"cartpole-two_poles", - # "time_limit": 1, - "camera_id": 0, - "episode_length": 1000, - "wrappers": [dmc.suite.cartpole.TwoPolesMPWrapper], - "mp_kwargs": { - "num_dof": 1, - "num_basis": 5, - "duration": 10, - "learn_goal": True, - "alpha_phase": 2, - "bandwidth_factor": 2, - "policy_type": "motor", - "weights_scale": 50, - "goal_scale": 0.1, - "policy_kwargs": { - "p_gains": 10, - "d_gains": 10 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(env_id) - -env_id = f'dmc_cartpole-two_poles_detpmp-v0' -register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": f"cartpole-two_poles", - # "time_limit": 1, - "camera_id": 0, - "episode_length": 1000, - "wrappers": [dmc.suite.cartpole.TwoPolesMPWrapper], - "mp_kwargs": { - "num_dof": 1, - "num_basis": 5, - "duration": 10, - "width": 0.025, - "policy_type": "motor", - "weights_scale": 0.2, - "zero_start": True, - "policy_kwargs": { - "p_gains": 10, - "d_gains": 10 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(env_id) - -env_id = f'dmc_cartpole-three_poles_dmp-v0' -register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"cartpole-three_poles", - # "time_limit": 1, - "camera_id": 0, - "episode_length": 1000, - "wrappers": [dmc.suite.cartpole.ThreePolesMPWrapper], - "mp_kwargs": { - "num_dof": 1, - "num_basis": 5, - "duration": 10, - "learn_goal": True, - "alpha_phase": 2, - "bandwidth_factor": 2, - "policy_type": "motor", - "weights_scale": 50, - "goal_scale": 0.1, - "policy_kwargs": { - "p_gains": 10, - "d_gains": 10 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(env_id) - -env_id = f'dmc_cartpole-three_poles_detpmp-v0' -register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": f"cartpole-three_poles", - # "time_limit": 1, - "camera_id": 0, - "episode_length": 1000, - "wrappers": [dmc.suite.cartpole.ThreePolesMPWrapper], - "mp_kwargs": { - "num_dof": 1, - "num_basis": 5, - "duration": 10, - "width": 0.025, - "policy_type": "motor", - "weights_scale": 0.2, - "zero_start": True, - "policy_kwargs": { - "p_gains": 10, - "d_gains": 10 - } - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(env_id) - -### Manipulation - -register( - id=f'dmc_manipulation-reach_site_dmp-v0', - entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', - # max_episode_steps=1, - kwargs={ - "name": f"manipulation-reach_site_features", - # "time_limit": 1, - "episode_length": 250, - "wrappers": [dmc.manipulation.reach.MPWrapper], - "mp_kwargs": { - "num_dof": 9, - "num_basis": 5, - "duration": 10, - "learn_goal": True, - "alpha_phase": 2, - "bandwidth_factor": 2, - "policy_type": "velocity", - "weights_scale": 50, - "goal_scale": 0.1, - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("dmc_manipulation-reach_site_dmp-v0") - -register( - id=f'dmc_manipulation-reach_site_detpmp-v0', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": f"manipulation-reach_site_features", - # "time_limit": 1, - "episode_length": 250, - "wrappers": [dmc.manipulation.reach.MPWrapper], - "mp_kwargs": { - "num_dof": 9, - "num_basis": 5, - "duration": 10, - "width": 0.025, - "policy_type": "velocity", - "weights_scale": 0.2, - "zero_start": True, - } - } -) -ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("dmc_manipulation-reach_site_detpmp-v0") - -## Open AI -register( - id='ContinuousMountainCarDetPMP-v0', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": "gym.envs.classic_control:MountainCarContinuous-v0", - "wrappers": [open_ai.classic_control.continuous_mountain_car.MPWrapper], - "mp_kwargs": { - "num_dof": 1, - "num_basis": 4, - "duration": 2, - "post_traj_time": 0, - "width": 0.02, - "zero_start": True, - "policy_type": "motor", - "policy_kwargs": { - "p_gains": 1., - "d_gains": 1. - } - } - } -) -ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("ContinuousMountainCarDetPMP-v0") - -register( - id='ReacherDetPMP-v2', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": "gym.envs.mujoco:Reacher-v2", - "wrappers": [open_ai.mujoco.reacher_v2.MPWrapper], - "mp_kwargs": { - "num_dof": 2, - "num_basis": 6, - "duration": 1, - "post_traj_time": 0, - "width": 0.02, - "zero_start": True, - "policy_type": "motor", - "policy_kwargs": { - "p_gains": .6, - "d_gains": .075 - } - } - } -) -ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("ReacherDetPMP-v2") - -register( - id='FetchSlideDenseDetPMP-v1', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": "gym.envs.robotics:FetchSlideDense-v1", - "wrappers": [FlattenObservation, open_ai.robotics.fetch.MPWrapper], - "mp_kwargs": { - "num_dof": 4, - "num_basis": 5, - "duration": 2, - "post_traj_time": 0, - "width": 0.02, - "zero_start": True, - "policy_type": "position" - } - } -) -ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("FetchSlideDenseDetPMP-v1") - -register( - id='FetchSlideDetPMP-v1', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": "gym.envs.robotics:FetchSlide-v1", - "wrappers": [FlattenObservation, open_ai.robotics.fetch.MPWrapper], - "mp_kwargs": { - "num_dof": 4, - "num_basis": 5, - "duration": 2, - "post_traj_time": 0, - "width": 0.02, - "zero_start": True, - "policy_type": "position" - } - } -) -ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("FetchSlideDetPMP-v1") - -register( - id='FetchReachDenseDetPMP-v1', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": "gym.envs.robotics:FetchReachDense-v1", - "wrappers": [FlattenObservation, open_ai.robotics.fetch.MPWrapper], - "mp_kwargs": { - "num_dof": 4, - "num_basis": 5, - "duration": 2, - "post_traj_time": 0, - "width": 0.02, - "zero_start": True, - "policy_type": "position" - } - } -) -ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("FetchReachDenseDetPMP-v1") - -register( - id='FetchReachDetPMP-v1', - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": "gym.envs.robotics:FetchReach-v1", - "wrappers": [FlattenObservation, open_ai.robotics.fetch.MPWrapper], - "mp_kwargs": { - "num_dof": 4, - "num_basis": 5, - "duration": 2, - "post_traj_time": 0, - "width": 0.02, - "zero_start": True, - "policy_type": "position" - } - } -) -ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("FetchReachDetPMP-v1") - -# MetaWorld - -goal_change_envs = ["assembly-v2", "pick-out-of-hole-v2", "plate-slide-v2", "plate-slide-back-v2", - ] -for task in goal_change_envs: - task_id_split = task.split("-") - name = "".join([s.capitalize() for s in task_id_split[:-1]]) - env_id = f'{name}DetPMP-{task_id_split[-1]}' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": task, - "wrappers": [meta.goal_change.MPWrapper], - "mp_kwargs": { - "num_dof": 4, - "num_basis": 5, - "duration": 6.25, - "post_traj_time": 0, - "width": 0.025, - "zero_start": True, - "policy_type": "metaworld", - } - } - ) - ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(env_id) - -object_change_envs = ["bin-picking-v2", "hammer-v2", "sweep-into-v2"] -for task in object_change_envs: - task_id_split = task.split("-") - name = "".join([s.capitalize() for s in task_id_split[:-1]]) - env_id = f'{name}DetPMP-{task_id_split[-1]}' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": task, - "wrappers": [meta.object_change.MPWrapper], - "mp_kwargs": { - "num_dof": 4, - "num_basis": 5, - "duration": 6.25, - "post_traj_time": 0, - "width": 0.025, - "zero_start": True, - "policy_type": "metaworld", - } - } - ) - ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(env_id) - -goal_and_object_change_envs = ["box-close-v2", "button-press-v2", "button-press-wall-v2", "button-press-topdown-v2", - "button-press-topdown-wall-v2", "coffee-button-v2", "coffee-pull-v2", - "coffee-push-v2", "dial-turn-v2", "disassemble-v2", "door-close-v2", - "door-lock-v2", "door-open-v2", "door-unlock-v2", "hand-insert-v2", - "drawer-close-v2", "drawer-open-v2", "faucet-open-v2", "faucet-close-v2", - "handle-press-side-v2", "handle-press-v2", "handle-pull-side-v2", - "handle-pull-v2", "lever-pull-v2", "peg-insert-side-v2", "pick-place-wall-v2", - "reach-v2", "push-back-v2", "push-v2", "pick-place-v2", "peg-unplug-side-v2", - "soccer-v2", "stick-push-v2", "stick-pull-v2", "push-wall-v2", "reach-wall-v2", - "shelf-place-v2", "sweep-v2", "window-open-v2", "window-close-v2" - ] -for task in goal_and_object_change_envs: - task_id_split = task.split("-") - name = "".join([s.capitalize() for s in task_id_split[:-1]]) - env_id = f'{name}DetPMP-{task_id_split[-1]}' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": task, - "wrappers": [meta.goal_and_object_change.MPWrapper], - "mp_kwargs": { - "num_dof": 4, - "num_basis": 5, - "duration": 6.25, - "post_traj_time": 0, - "width": 0.025, - "zero_start": True, - "policy_type": "metaworld", - } - } - ) - ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(env_id) - -goal_and_endeffector_change_envs = ["basketball-v2"] -for task in goal_and_endeffector_change_envs: - task_id_split = task.split("-") - name = "".join([s.capitalize() for s in task_id_split[:-1]]) - env_id = f'{name}DetPMP-{task_id_split[-1]}' - register( - id=env_id, - entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', - kwargs={ - "name": task, - "wrappers": [meta.goal_and_endeffector_change.MPWrapper], - "mp_kwargs": { - "num_dof": 4, - "num_basis": 5, - "duration": 6.25, - "post_traj_time": 0, - "width": 0.025, - "zero_start": True, - "policy_type": "metaworld", - } - } - ) - ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(env_id) +ALL_MOTION_PRIMITIVE_ENVIRONMENTS = { + key: value + ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS[key] + + ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS[key] + + ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS[key] + for key, value in ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS.items()} diff --git a/alr_envs/alr/__init__.py b/alr_envs/alr/__init__.py new file mode 100644 index 0000000..179839c --- /dev/null +++ b/alr_envs/alr/__init__.py @@ -0,0 +1,329 @@ +from gym import register + +from . import classic_control, mujoco +from .classic_control.hole_reacher.hole_reacher import HoleReacherEnv +from .classic_control.simple_reacher.simple_reacher import SimpleReacherEnv +from .classic_control.viapoint_reacher.viapoint_reacher import ViaPointReacherEnv +from .mujoco.ball_in_a_cup.ball_in_a_cup import ALRBallInACupEnv +from .mujoco.ball_in_a_cup.biac_pd import ALRBallInACupPDEnv +from .mujoco.reacher.alr_reacher import ALRReacherEnv +from .mujoco.reacher.balancing import BalancingEnv + +ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "DetPMP": []} + +# Classic Control +## Simple Reacher +register( + id='SimpleReacher-v0', + entry_point='alr_envs.alr.classic_control:SimpleReacherEnv', + max_episode_steps=200, + kwargs={ + "n_links": 2, + } +) + +register( + id='SimpleReacher-v1', + entry_point='alr_envs.alr.classic_control:SimpleReacherEnv', + max_episode_steps=200, + kwargs={ + "n_links": 2, + "random_start": False + } +) + +register( + id='LongSimpleReacher-v0', + entry_point='alr_envs.alr.classic_control:SimpleReacherEnv', + max_episode_steps=200, + kwargs={ + "n_links": 5, + } +) + +register( + id='LongSimpleReacher-v1', + entry_point='alr_envs.alr.classic_control:SimpleReacherEnv', + max_episode_steps=200, + kwargs={ + "n_links": 5, + "random_start": False + } +) + +## Viapoint Reacher + +register( + id='ViaPointReacher-v0', + entry_point='alr_envs.alr.classic_control:ViaPointReacherEnv', + max_episode_steps=200, + kwargs={ + "n_links": 5, + "allow_self_collision": False, + "collision_penalty": 1000 + } +) + +## Hole Reacher +register( + id='HoleReacher-v0', + entry_point='alr_envs.alr.classic_control:HoleReacherEnv', + max_episode_steps=200, + kwargs={ + "n_links": 5, + "random_start": True, + "allow_self_collision": False, + "allow_wall_collision": False, + "hole_width": None, + "hole_depth": 1, + "hole_x": None, + "collision_penalty": 100, + } +) + +register( + id='HoleReacher-v1', + entry_point='alr_envs.alr.classic_control:HoleReacherEnv', + max_episode_steps=200, + kwargs={ + "n_links": 5, + "random_start": False, + "allow_self_collision": False, + "allow_wall_collision": False, + "hole_width": 0.25, + "hole_depth": 1, + "hole_x": None, + "collision_penalty": 100, + } +) + +register( + id='HoleReacher-v2', + entry_point='alr_envs.alr.classic_control:HoleReacherEnv', + max_episode_steps=200, + kwargs={ + "n_links": 5, + "random_start": False, + "allow_self_collision": False, + "allow_wall_collision": False, + "hole_width": 0.25, + "hole_depth": 1, + "hole_x": 2, + "collision_penalty": 100, + } +) + +# Mujoco + +## Reacher +register( + id='ALRReacher-v0', + entry_point='alr_envs.alr.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 0, + "n_links": 5, + "balance": False, + } +) + +register( + id='ALRReacherSparse-v0', + entry_point='alr_envs.alr.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 200, + "n_links": 5, + "balance": False, + } +) + +register( + id='ALRReacherSparseBalanced-v0', + entry_point='alr_envs.alr.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 200, + "n_links": 5, + "balance": True, + } +) + +register( + id='ALRLongReacher-v0', + entry_point='alr_envs.alr.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 0, + "n_links": 7, + "balance": False, + } +) + +register( + id='ALRLongReacherSparse-v0', + entry_point='alr_envs.alr.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 200, + "n_links": 7, + "balance": False, + } +) + +register( + id='ALRLongReacherSparseBalanced-v0', + entry_point='alr_envs.alr.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 200, + "n_links": 7, + "balance": True, + } +) + +## Balancing Reacher + +register( + id='Balancing-v0', + entry_point='alr_envs.alr.mujoco:BalancingEnv', + max_episode_steps=200, + kwargs={ + "n_links": 5, + } +) + +# Motion Primitive Environments + +## Simple Reacher +_versions = ["SimpleReacher-v0", "SimpleReacher-v1", "LongSimpleReacher-v0", "LongSimpleReacher-v1"] +for _v in _versions: + _name = _v.split("-") + _env_id = f'{_name[0]}DMP-{_name[1]}' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"alr_envs:{_v}", + "wrappers": [classic_control.simple_reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 2 if "long" not in _v.lower() else 5, + "num_basis": 5, + "duration": 20, + "alpha_phase": 2, + "learn_goal": True, + "policy_type": "velocity", + "weights_scale": 50, + } + } + ) + ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(_env_id) + + _env_id = f'{_name[0]}DetPMP-{_name[1]}' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"alr_envs:{_v}", + "wrappers": [classic_control.simple_reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 2 if "long" not in _v.lower() else 5, + "num_basis": 5, + "duration": 20, + "width": 0.025, + "policy_type": "velocity", + "weights_scale": 0.2, + "zero_start": True + } + } + ) + ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(_env_id) + +# Viapoint reacher +register( + id='ViaPointReacherDMP-v0', + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": "alr_envs:ViaPointReacher-v0", + "wrappers": [classic_control.viapoint_reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 5, + "num_basis": 5, + "duration": 2, + "learn_goal": True, + "alpha_phase": 2, + "policy_type": "velocity", + "weights_scale": 50, + } + } +) +ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("ViaPointReacherDMP-v0") + +register( + id='ViaPointReacherDetPMP-v0', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": "alr_envs:ViaPointReacher-v0", + "wrappers": [classic_control.viapoint_reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 5, + "num_basis": 5, + "duration": 2, + "width": 0.025, + "policy_type": "velocity", + "weights_scale": 0.2, + "zero_start": True + } + } +) +ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("ViaPointReacherDetPMP-v0") + +## Hole Reacher +_versions = ["v0", "v1", "v2"] +for _v in _versions: + _env_id = f'HoleReacherDMP-{_v}' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"alr_envs:HoleReacher-{_v}", + "wrappers": [classic_control.hole_reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 5, + "num_basis": 5, + "duration": 2, + "learn_goal": True, + "alpha_phase": 2, + "bandwidth_factor": 2, + "policy_type": "velocity", + "weights_scale": 50, + "goal_scale": 0.1 + } + } + ) + ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(_env_id) + + _env_id = f'HoleReacherDetPMP-{_v}' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": f"alr_envs:HoleReacher-{_v}", + "wrappers": [classic_control.hole_reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 5, + "num_basis": 5, + "duration": 2, + "width": 0.025, + "policy_type": "velocity", + "weights_scale": 0.2, + "zero_start": True + } + } + ) + ALL_ALR_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(_env_id) diff --git a/alr_envs/classic_control/README.MD b/alr_envs/alr/classic_control/README.MD similarity index 100% rename from alr_envs/classic_control/README.MD rename to alr_envs/alr/classic_control/README.MD diff --git a/alr_envs/alr/classic_control/__init__.py b/alr_envs/alr/classic_control/__init__.py new file mode 100644 index 0000000..73575ab --- /dev/null +++ b/alr_envs/alr/classic_control/__init__.py @@ -0,0 +1,3 @@ +from .hole_reacher.hole_reacher import HoleReacherEnv +from .simple_reacher.simple_reacher import SimpleReacherEnv +from .viapoint_reacher.viapoint_reacher import ViaPointReacherEnv diff --git a/alr_envs/classic_control/hole_reacher/__init__.py b/alr_envs/alr/classic_control/hole_reacher/__init__.py similarity index 100% rename from alr_envs/classic_control/hole_reacher/__init__.py rename to alr_envs/alr/classic_control/hole_reacher/__init__.py diff --git a/alr_envs/classic_control/hole_reacher/hole_reacher.py b/alr_envs/alr/classic_control/hole_reacher/hole_reacher.py similarity index 99% rename from alr_envs/classic_control/hole_reacher/hole_reacher.py rename to alr_envs/alr/classic_control/hole_reacher/hole_reacher.py index 2482714..ee1a997 100644 --- a/alr_envs/classic_control/hole_reacher/hole_reacher.py +++ b/alr_envs/alr/classic_control/hole_reacher/hole_reacher.py @@ -6,7 +6,7 @@ import numpy as np from gym.utils import seeding from matplotlib import patches -from alr_envs.classic_control.utils import check_self_collision +from alr_envs.alr.classic_control.utils import check_self_collision class HoleReacherEnv(gym.Env): diff --git a/alr_envs/classic_control/hole_reacher/mp_wrapper.py b/alr_envs/alr/classic_control/hole_reacher/mp_wrapper.py similarity index 100% rename from alr_envs/classic_control/hole_reacher/mp_wrapper.py rename to alr_envs/alr/classic_control/hole_reacher/mp_wrapper.py diff --git a/alr_envs/classic_control/simple_reacher/__init__.py b/alr_envs/alr/classic_control/simple_reacher/__init__.py similarity index 100% rename from alr_envs/classic_control/simple_reacher/__init__.py rename to alr_envs/alr/classic_control/simple_reacher/__init__.py diff --git a/alr_envs/classic_control/simple_reacher/mp_wrapper.py b/alr_envs/alr/classic_control/simple_reacher/mp_wrapper.py similarity index 100% rename from alr_envs/classic_control/simple_reacher/mp_wrapper.py rename to alr_envs/alr/classic_control/simple_reacher/mp_wrapper.py diff --git a/alr_envs/classic_control/simple_reacher/simple_reacher.py b/alr_envs/alr/classic_control/simple_reacher/simple_reacher.py similarity index 100% rename from alr_envs/classic_control/simple_reacher/simple_reacher.py rename to alr_envs/alr/classic_control/simple_reacher/simple_reacher.py diff --git a/alr_envs/classic_control/utils.py b/alr_envs/alr/classic_control/utils.py similarity index 100% rename from alr_envs/classic_control/utils.py rename to alr_envs/alr/classic_control/utils.py diff --git a/alr_envs/classic_control/viapoint_reacher/__init__.py b/alr_envs/alr/classic_control/viapoint_reacher/__init__.py similarity index 100% rename from alr_envs/classic_control/viapoint_reacher/__init__.py rename to alr_envs/alr/classic_control/viapoint_reacher/__init__.py diff --git a/alr_envs/classic_control/viapoint_reacher/mp_wrapper.py b/alr_envs/alr/classic_control/viapoint_reacher/mp_wrapper.py similarity index 100% rename from alr_envs/classic_control/viapoint_reacher/mp_wrapper.py rename to alr_envs/alr/classic_control/viapoint_reacher/mp_wrapper.py diff --git a/alr_envs/classic_control/viapoint_reacher/viapoint_reacher.py b/alr_envs/alr/classic_control/viapoint_reacher/viapoint_reacher.py similarity index 99% rename from alr_envs/classic_control/viapoint_reacher/viapoint_reacher.py rename to alr_envs/alr/classic_control/viapoint_reacher/viapoint_reacher.py index 99f8bcf..95d1e7f 100644 --- a/alr_envs/classic_control/viapoint_reacher/viapoint_reacher.py +++ b/alr_envs/alr/classic_control/viapoint_reacher/viapoint_reacher.py @@ -5,10 +5,10 @@ import matplotlib.pyplot as plt import numpy as np from gym.utils import seeding -from alr_envs.classic_control.utils import check_self_collision +from alr_envs.alr.classic_control.utils import check_self_collision -class ViaPointReacher(gym.Env): +class ViaPointReacherEnv(gym.Env): def __init__(self, n_links, random_start: bool = False, via_target: Union[None, Iterable] = None, target: Union[None, Iterable] = None, allow_self_collision=False, collision_penalty=1000): diff --git a/alr_envs/mujoco/README.MD b/alr_envs/alr/mujoco/README.MD similarity index 100% rename from alr_envs/mujoco/README.MD rename to alr_envs/alr/mujoco/README.MD diff --git a/alr_envs/alr/mujoco/__init__.py b/alr_envs/alr/mujoco/__init__.py new file mode 100644 index 0000000..6744d15 --- /dev/null +++ b/alr_envs/alr/mujoco/__init__.py @@ -0,0 +1,4 @@ +from .reacher.alr_reacher import ALRReacherEnv +from .reacher.balancing import BalancingEnv +from .ball_in_a_cup.ball_in_a_cup import ALRBallInACupEnv +from .ball_in_a_cup.biac_pd import ALRBallInACupPDEnv \ No newline at end of file diff --git a/alr_envs/mujoco/alr_reward_fct.py b/alr_envs/alr/mujoco/alr_reward_fct.py similarity index 100% rename from alr_envs/mujoco/alr_reward_fct.py rename to alr_envs/alr/mujoco/alr_reward_fct.py diff --git a/alr_envs/mujoco/ball_in_a_cup/__init__.py b/alr_envs/alr/mujoco/ball_in_a_cup/__init__.py similarity index 100% rename from alr_envs/mujoco/ball_in_a_cup/__init__.py rename to alr_envs/alr/mujoco/ball_in_a_cup/__init__.py diff --git a/alr_envs/mujoco/ball_in_a_cup/assets/biac_base.xml b/alr_envs/alr/mujoco/ball_in_a_cup/assets/biac_base.xml similarity index 100% rename from alr_envs/mujoco/ball_in_a_cup/assets/biac_base.xml rename to alr_envs/alr/mujoco/ball_in_a_cup/assets/biac_base.xml diff --git a/alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup.py b/alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup.py similarity index 96% rename from alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup.py rename to alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup.py index f870877..7cff670 100644 --- a/alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup.py +++ b/alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup.py @@ -35,10 +35,10 @@ class ALRBallInACupEnv(MujocoEnv, utils.EzPickle): self.sim_time = 8 # seconds self.sim_steps = int(self.sim_time / self.dt) if reward_type == "no_context": - from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup_reward_simple import BallInACupReward + from alr_envs.alr.mujoco.ball_in_a_cup.ball_in_a_cup_reward_simple import BallInACupReward reward_function = BallInACupReward elif reward_type == "contextual_goal": - from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup_reward import BallInACupReward + from alr_envs.alr.mujoco.ball_in_a_cup.ball_in_a_cup_reward import BallInACupReward reward_function = BallInACupReward else: raise ValueError("Unknown reward type: {}".format(reward_type)) diff --git a/alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_mp_wrapper.py b/alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup_mp_wrapper.py similarity index 100% rename from alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_mp_wrapper.py rename to alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup_mp_wrapper.py diff --git a/alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward.py b/alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup_reward.py similarity index 99% rename from alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward.py rename to alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup_reward.py index e34aecf..4ea4381 100644 --- a/alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward.py +++ b/alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup_reward.py @@ -1,5 +1,5 @@ import numpy as np -from alr_envs.mujoco import alr_reward_fct +from alr_envs.alr.mujoco import alr_reward_fct class BallInACupReward(alr_reward_fct.AlrReward): diff --git a/alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward_simple.py b/alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup_reward_simple.py similarity index 99% rename from alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward_simple.py rename to alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup_reward_simple.py index 295dcf9..a147d89 100644 --- a/alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward_simple.py +++ b/alr_envs/alr/mujoco/ball_in_a_cup/ball_in_a_cup_reward_simple.py @@ -1,5 +1,5 @@ import numpy as np -from alr_envs.mujoco import alr_reward_fct +from alr_envs.alr.mujoco import alr_reward_fct class BallInACupReward(alr_reward_fct.AlrReward): diff --git a/alr_envs/mujoco/ball_in_a_cup/biac_pd.py b/alr_envs/alr/mujoco/ball_in_a_cup/biac_pd.py similarity index 97% rename from alr_envs/mujoco/ball_in_a_cup/biac_pd.py rename to alr_envs/alr/mujoco/ball_in_a_cup/biac_pd.py index 31545d0..b047c54 100644 --- a/alr_envs/mujoco/ball_in_a_cup/biac_pd.py +++ b/alr_envs/alr/mujoco/ball_in_a_cup/biac_pd.py @@ -42,10 +42,10 @@ class ALRBallInACupPDEnv(mujoco_env.MujocoEnv, utils.EzPickle): self._dt = 0.02 self.ep_length = 4000 # based on 8 seconds with dt = 0.02 int(self.sim_time / self.dt) if reward_type == "no_context": - from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup_reward_simple import BallInACupReward + from alr_envs.alr.mujoco.ball_in_a_cup.ball_in_a_cup_reward_simple import BallInACupReward reward_function = BallInACupReward elif reward_type == "contextual_goal": - from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup_reward import BallInACupReward + from alr_envs.alr.mujoco.ball_in_a_cup.ball_in_a_cup_reward import BallInACupReward reward_function = BallInACupReward else: raise ValueError("Unknown reward type: {}".format(reward_type)) diff --git a/alr_envs/mujoco/ball_in_a_cup/utils.py b/alr_envs/alr/mujoco/ball_in_a_cup/utils.py similarity index 97% rename from alr_envs/mujoco/ball_in_a_cup/utils.py rename to alr_envs/alr/mujoco/ball_in_a_cup/utils.py index b851cae..0dd972c 100644 --- a/alr_envs/mujoco/ball_in_a_cup/utils.py +++ b/alr_envs/alr/mujoco/ball_in_a_cup/utils.py @@ -1,4 +1,4 @@ -from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup import ALRBallInACupEnv +from alr_envs.alr.mujoco.ball_in_a_cup.ball_in_a_cup import ALRBallInACupEnv from mp_env_api.mp_wrappers.detpmp_wrapper import DetPMPWrapper from mp_env_api.mp_wrappers.dmp_wrapper import DmpWrapper diff --git a/alr_envs/mujoco/beerpong/__init__.py b/alr_envs/alr/mujoco/beerpong/__init__.py similarity index 100% rename from alr_envs/mujoco/beerpong/__init__.py rename to alr_envs/alr/mujoco/beerpong/__init__.py diff --git a/alr_envs/mujoco/beerpong/assets/beerpong.xml b/alr_envs/alr/mujoco/beerpong/assets/beerpong.xml similarity index 100% rename from alr_envs/mujoco/beerpong/assets/beerpong.xml rename to alr_envs/alr/mujoco/beerpong/assets/beerpong.xml diff --git a/alr_envs/mujoco/beerpong/beerpong.py b/alr_envs/alr/mujoco/beerpong/beerpong.py similarity index 98% rename from alr_envs/mujoco/beerpong/beerpong.py rename to alr_envs/alr/mujoco/beerpong/beerpong.py index 1f3f781..4d8f389 100644 --- a/alr_envs/mujoco/beerpong/beerpong.py +++ b/alr_envs/alr/mujoco/beerpong/beerpong.py @@ -37,7 +37,7 @@ class ALRBeerpongEnv(MujocoEnv, utils.EzPickle): self.sim_time = 8 # seconds self.sim_steps = int(self.sim_time / self.dt) if reward_function is None: - from alr_envs.mujoco.beerpong.beerpong_reward import BeerpongReward + from alr_envs.alr.mujoco.beerpong.beerpong_reward import BeerpongReward reward_function = BeerpongReward self.reward_function = reward_function(self.sim, self.sim_steps) self.cup_robot_id = self.sim.model._site_name2id["cup_robot_final"] diff --git a/alr_envs/mujoco/beerpong/beerpong_reward.py b/alr_envs/alr/mujoco/beerpong/beerpong_reward.py similarity index 99% rename from alr_envs/mujoco/beerpong/beerpong_reward.py rename to alr_envs/alr/mujoco/beerpong/beerpong_reward.py index 3281409..c3ca3c6 100644 --- a/alr_envs/mujoco/beerpong/beerpong_reward.py +++ b/alr_envs/alr/mujoco/beerpong/beerpong_reward.py @@ -1,5 +1,5 @@ import numpy as np -from alr_envs.mujoco import alr_reward_fct +from alr_envs.alr.mujoco import alr_reward_fct class BeerpongReward(alr_reward_fct.AlrReward): diff --git a/alr_envs/mujoco/beerpong/beerpong_reward_simple.py b/alr_envs/alr/mujoco/beerpong/beerpong_reward_simple.py similarity index 99% rename from alr_envs/mujoco/beerpong/beerpong_reward_simple.py rename to alr_envs/alr/mujoco/beerpong/beerpong_reward_simple.py index b79e963..fbe2163 100644 --- a/alr_envs/mujoco/beerpong/beerpong_reward_simple.py +++ b/alr_envs/alr/mujoco/beerpong/beerpong_reward_simple.py @@ -1,5 +1,5 @@ import numpy as np -from alr_envs.mujoco import alr_reward_fct +from alr_envs.alr.mujoco import alr_reward_fct class BeerpongReward(alr_reward_fct.AlrReward): diff --git a/alr_envs/mujoco/beerpong/beerpong_simple.py b/alr_envs/alr/mujoco/beerpong/beerpong_simple.py similarity index 98% rename from alr_envs/mujoco/beerpong/beerpong_simple.py rename to alr_envs/alr/mujoco/beerpong/beerpong_simple.py index 5f6f6d2..73da83d 100644 --- a/alr_envs/mujoco/beerpong/beerpong_simple.py +++ b/alr_envs/alr/mujoco/beerpong/beerpong_simple.py @@ -38,7 +38,7 @@ class ALRBeerpongEnv(MujocoEnv, utils.EzPickle): self.sim_time = 8 # seconds self.sim_steps = int(self.sim_time / self.dt) if reward_function is None: - from alr_envs.mujoco.beerpong.beerpong_reward_simple import BeerpongReward + from alr_envs.alr.mujoco.beerpong.beerpong_reward_simple import BeerpongReward reward_function = BeerpongReward self.reward_function = reward_function(self.sim, self.sim_steps) self.cup_robot_id = self.sim.model._site_name2id["cup_robot_final"] diff --git a/alr_envs/mujoco/beerpong/utils.py b/alr_envs/alr/mujoco/beerpong/utils.py similarity index 93% rename from alr_envs/mujoco/beerpong/utils.py rename to alr_envs/alr/mujoco/beerpong/utils.py index 7cd4682..f43e881 100644 --- a/alr_envs/mujoco/beerpong/utils.py +++ b/alr_envs/alr/mujoco/beerpong/utils.py @@ -1,6 +1,6 @@ from alr_envs.utils.mps.detpmp_wrapper import DetPMPWrapper -from alr_envs.mujoco.beerpong.beerpong import ALRBeerpongEnv -from alr_envs.mujoco.beerpong.beerpong_simple import ALRBeerpongEnv as ALRBeerpongEnvSimple +from alr_envs.alr.mujoco.beerpong.beerpong import ALRBeerpongEnv +from alr_envs.alr.mujoco.beerpong.beerpong_simple import ALRBeerpongEnv as ALRBeerpongEnvSimple def make_contextual_env(rank, seed=0): diff --git a/alr_envs/mujoco/gym_table_tennis/__init__.py b/alr_envs/alr/mujoco/gym_table_tennis/__init__.py similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/__init__.py rename to alr_envs/alr/mujoco/gym_table_tennis/__init__.py diff --git a/alr_envs/mujoco/gym_table_tennis/envs/__init__.py b/alr_envs/alr/mujoco/gym_table_tennis/envs/__init__.py similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/__init__.py rename to alr_envs/alr/mujoco/gym_table_tennis/envs/__init__.py diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/include_7_motor_actuator.xml b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_7_motor_actuator.xml similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/include_7_motor_actuator.xml rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_7_motor_actuator.xml diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/include_barrett_wam_7dof_left.xml b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_barrett_wam_7dof_left.xml similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/include_barrett_wam_7dof_left.xml rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_barrett_wam_7dof_left.xml diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/include_barrett_wam_7dof_right.xml b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_barrett_wam_7dof_right.xml similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/include_barrett_wam_7dof_right.xml rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_barrett_wam_7dof_right.xml diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/include_table.xml b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_table.xml similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/include_table.xml rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_table.xml diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/include_target_ball.xml b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_target_ball.xml similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/include_target_ball.xml rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_target_ball.xml diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/include_test_balls.xml b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_test_balls.xml similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/include_test_balls.xml rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/include_test_balls.xml diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/base_link_convex.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/base_link_convex.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/base_link_convex.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/base_link_convex.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/base_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/base_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/base_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/base_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_dist_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_dist_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_dist_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_dist_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_med_link_convex.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_med_link_convex.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_med_link_convex.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_med_link_convex.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_med_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_med_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_med_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_med_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p3.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p3.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p3.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p3.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p3.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p3.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p3.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p3.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p4.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p4.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p4.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_link_convex_decomposition_p4.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/elbow_link_convex.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/elbow_link_convex.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/elbow_link_convex.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/elbow_link_convex.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/forearm_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p3.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p3.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p3.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_convex_decomposition_p3.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_pitch_link_convex.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_pitch_link_convex.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_pitch_link_convex.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_pitch_link_convex.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_pitch_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_pitch_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_pitch_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/shoulder_pitch_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/upper_arm_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_palm_link_convex.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_palm_link_convex.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_palm_link_convex.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_palm_link_convex.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p3.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p3.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p3.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_convex_decomposition_p3.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_pitch_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_fine.stl b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_fine.stl similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_fine.stl rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/meshes/wrist_yaw_link_fine.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/right_arm_actuator.xml b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/right_arm_actuator.xml similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/right_arm_actuator.xml rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/right_arm_actuator.xml diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/shared.xml b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/shared.xml similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/shared.xml rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/shared.xml diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/table_tennis_env.xml b/alr_envs/alr/mujoco/gym_table_tennis/envs/assets/table_tennis_env.xml similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/table_tennis_env.xml rename to alr_envs/alr/mujoco/gym_table_tennis/envs/assets/table_tennis_env.xml diff --git a/alr_envs/mujoco/gym_table_tennis/envs/table_tennis_env.py b/alr_envs/alr/mujoco/gym_table_tennis/envs/table_tennis_env.py similarity index 98% rename from alr_envs/mujoco/gym_table_tennis/envs/table_tennis_env.py rename to alr_envs/alr/mujoco/gym_table_tennis/envs/table_tennis_env.py index f155f06..9b16ae1 100644 --- a/alr_envs/mujoco/gym_table_tennis/envs/table_tennis_env.py +++ b/alr_envs/alr/mujoco/gym_table_tennis/envs/table_tennis_env.py @@ -2,9 +2,9 @@ import numpy as np from gym import spaces from gym.envs.robotics import robot_env, utils # import xml.etree.ElementTree as ET -from alr_envs.mujoco.gym_table_tennis.utils.rewards.hierarchical_reward import HierarchicalRewardTableTennis +from alr_envs.alr.mujoco.gym_table_tennis.utils.rewards.hierarchical_reward import HierarchicalRewardTableTennis import glfw -from alr_envs.mujoco.gym_table_tennis.utils.experiment import ball_initialize +from alr_envs.alr.mujoco.gym_table_tennis.utils.experiment import ball_initialize from pathlib import Path import os diff --git a/alr_envs/mujoco/gym_table_tennis/utils/__init__.py b/alr_envs/alr/mujoco/gym_table_tennis/utils/__init__.py similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/utils/__init__.py rename to alr_envs/alr/mujoco/gym_table_tennis/utils/__init__.py diff --git a/alr_envs/mujoco/gym_table_tennis/utils/experiment.py b/alr_envs/alr/mujoco/gym_table_tennis/utils/experiment.py similarity index 96% rename from alr_envs/mujoco/gym_table_tennis/utils/experiment.py rename to alr_envs/alr/mujoco/gym_table_tennis/utils/experiment.py index addd6c5..a106d68 100644 --- a/alr_envs/mujoco/gym_table_tennis/utils/experiment.py +++ b/alr_envs/alr/mujoco/gym_table_tennis/utils/experiment.py @@ -1,6 +1,6 @@ import numpy as np from gym.utils import seeding -from alr_envs.mujoco.gym_table_tennis.utils.util import read_yaml, read_json +from alr_envs.alr.mujoco.gym_table_tennis.utils.util import read_yaml, read_json from pathlib import Path diff --git a/alr_envs/mujoco/gym_table_tennis/utils/rewards/__init__.py b/alr_envs/alr/mujoco/gym_table_tennis/utils/rewards/__init__.py similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/utils/rewards/__init__.py rename to alr_envs/alr/mujoco/gym_table_tennis/utils/rewards/__init__.py diff --git a/alr_envs/mujoco/gym_table_tennis/utils/rewards/hierarchical_reward.py b/alr_envs/alr/mujoco/gym_table_tennis/utils/rewards/hierarchical_reward.py similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/utils/rewards/hierarchical_reward.py rename to alr_envs/alr/mujoco/gym_table_tennis/utils/rewards/hierarchical_reward.py diff --git a/alr_envs/mujoco/gym_table_tennis/utils/rewards/rewards.py b/alr_envs/alr/mujoco/gym_table_tennis/utils/rewards/rewards.py similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/utils/rewards/rewards.py rename to alr_envs/alr/mujoco/gym_table_tennis/utils/rewards/rewards.py diff --git a/alr_envs/mujoco/gym_table_tennis/utils/util.py b/alr_envs/alr/mujoco/gym_table_tennis/utils/util.py similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/utils/util.py rename to alr_envs/alr/mujoco/gym_table_tennis/utils/util.py diff --git a/alr_envs/mujoco/meshes/wam/base_link_convex.stl b/alr_envs/alr/mujoco/meshes/wam/base_link_convex.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/base_link_convex.stl rename to alr_envs/alr/mujoco/meshes/wam/base_link_convex.stl diff --git a/alr_envs/mujoco/meshes/wam/base_link_fine.stl b/alr_envs/alr/mujoco/meshes/wam/base_link_fine.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/base_link_fine.stl rename to alr_envs/alr/mujoco/meshes/wam/base_link_fine.stl diff --git a/alr_envs/mujoco/meshes/wam/cup.stl b/alr_envs/alr/mujoco/meshes/wam/cup.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup.stl rename to alr_envs/alr/mujoco/meshes/wam/cup.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split1.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split1.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split1.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split1.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split10.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split10.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split10.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split10.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split11.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split11.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split11.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split11.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split12.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split12.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split12.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split12.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split13.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split13.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split13.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split13.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split14.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split14.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split14.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split14.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split15.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split15.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split15.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split15.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split16.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split16.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split16.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split16.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split17.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split17.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split17.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split17.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split18.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split18.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split18.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split18.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split2.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split2.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split2.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split2.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split3.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split3.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split3.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split3.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split4.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split4.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split4.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split4.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split5.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split5.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split5.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split5.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split6.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split6.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split6.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split6.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split7.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split7.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split7.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split7.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split8.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split8.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split8.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split8.stl diff --git a/alr_envs/mujoco/meshes/wam/cup_split9.stl b/alr_envs/alr/mujoco/meshes/wam/cup_split9.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/cup_split9.stl rename to alr_envs/alr/mujoco/meshes/wam/cup_split9.stl diff --git a/alr_envs/mujoco/meshes/wam/elbow_link_convex.stl b/alr_envs/alr/mujoco/meshes/wam/elbow_link_convex.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/elbow_link_convex.stl rename to alr_envs/alr/mujoco/meshes/wam/elbow_link_convex.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/elbow_link_fine.stl b/alr_envs/alr/mujoco/meshes/wam/elbow_link_fine.stl old mode 100644 new mode 100755 similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/elbow_link_fine.stl rename to alr_envs/alr/mujoco/meshes/wam/elbow_link_fine.stl diff --git a/alr_envs/mujoco/meshes/wam/forearm_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/meshes/wam/forearm_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/forearm_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/meshes/wam/forearm_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/meshes/wam/forearm_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/meshes/wam/forearm_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/forearm_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/meshes/wam/forearm_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/meshes/wam/forearm_link_fine.stl b/alr_envs/alr/mujoco/meshes/wam/forearm_link_fine.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/forearm_link_fine.stl rename to alr_envs/alr/mujoco/meshes/wam/forearm_link_fine.stl diff --git a/alr_envs/mujoco/meshes/wam/shoulder_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/meshes/wam/shoulder_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/shoulder_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/meshes/wam/shoulder_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/meshes/wam/shoulder_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/meshes/wam/shoulder_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/shoulder_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/meshes/wam/shoulder_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/meshes/wam/shoulder_link_convex_decomposition_p3.stl b/alr_envs/alr/mujoco/meshes/wam/shoulder_link_convex_decomposition_p3.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/shoulder_link_convex_decomposition_p3.stl rename to alr_envs/alr/mujoco/meshes/wam/shoulder_link_convex_decomposition_p3.stl diff --git a/alr_envs/mujoco/meshes/wam/shoulder_link_fine.stl b/alr_envs/alr/mujoco/meshes/wam/shoulder_link_fine.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/shoulder_link_fine.stl rename to alr_envs/alr/mujoco/meshes/wam/shoulder_link_fine.stl diff --git a/alr_envs/mujoco/meshes/wam/shoulder_pitch_link_convex.stl b/alr_envs/alr/mujoco/meshes/wam/shoulder_pitch_link_convex.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/shoulder_pitch_link_convex.stl rename to alr_envs/alr/mujoco/meshes/wam/shoulder_pitch_link_convex.stl diff --git a/alr_envs/mujoco/meshes/wam/shoulder_pitch_link_fine.stl b/alr_envs/alr/mujoco/meshes/wam/shoulder_pitch_link_fine.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/shoulder_pitch_link_fine.stl rename to alr_envs/alr/mujoco/meshes/wam/shoulder_pitch_link_fine.stl diff --git a/alr_envs/mujoco/meshes/wam/upper_arm_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/meshes/wam/upper_arm_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/upper_arm_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/meshes/wam/upper_arm_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/meshes/wam/upper_arm_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/meshes/wam/upper_arm_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/upper_arm_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/meshes/wam/upper_arm_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/meshes/wam/upper_arm_link_fine.stl b/alr_envs/alr/mujoco/meshes/wam/upper_arm_link_fine.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/upper_arm_link_fine.stl rename to alr_envs/alr/mujoco/meshes/wam/upper_arm_link_fine.stl diff --git a/alr_envs/mujoco/meshes/wam/wrist_palm_link_convex.stl b/alr_envs/alr/mujoco/meshes/wam/wrist_palm_link_convex.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/wrist_palm_link_convex.stl rename to alr_envs/alr/mujoco/meshes/wam/wrist_palm_link_convex.stl diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_palm_link_fine.stl b/alr_envs/alr/mujoco/meshes/wam/wrist_palm_link_fine.stl old mode 100644 new mode 100755 similarity index 100% rename from alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/wrist_palm_link_fine.stl rename to alr_envs/alr/mujoco/meshes/wam/wrist_palm_link_fine.stl diff --git a/alr_envs/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p3.stl b/alr_envs/alr/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p3.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p3.stl rename to alr_envs/alr/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p3.stl diff --git a/alr_envs/mujoco/meshes/wam/wrist_yaw_link_convex_decomposition_p1.stl b/alr_envs/alr/mujoco/meshes/wam/wrist_yaw_link_convex_decomposition_p1.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/wrist_yaw_link_convex_decomposition_p1.stl rename to alr_envs/alr/mujoco/meshes/wam/wrist_yaw_link_convex_decomposition_p1.stl diff --git a/alr_envs/mujoco/meshes/wam/wrist_yaw_link_convex_decomposition_p2.stl b/alr_envs/alr/mujoco/meshes/wam/wrist_yaw_link_convex_decomposition_p2.stl similarity index 100% rename from alr_envs/mujoco/meshes/wam/wrist_yaw_link_convex_decomposition_p2.stl rename to alr_envs/alr/mujoco/meshes/wam/wrist_yaw_link_convex_decomposition_p2.stl diff --git a/alr_envs/mujoco/reacher/__init__.py b/alr_envs/alr/mujoco/reacher/__init__.py similarity index 100% rename from alr_envs/mujoco/reacher/__init__.py rename to alr_envs/alr/mujoco/reacher/__init__.py diff --git a/alr_envs/mujoco/reacher/assets/reacher_5links.xml b/alr_envs/alr/mujoco/reacher/assets/reacher_5links.xml similarity index 100% rename from alr_envs/mujoco/reacher/assets/reacher_5links.xml rename to alr_envs/alr/mujoco/reacher/assets/reacher_5links.xml diff --git a/alr_envs/mujoco/reacher/assets/reacher_7links.xml b/alr_envs/alr/mujoco/reacher/assets/reacher_7links.xml similarity index 100% rename from alr_envs/mujoco/reacher/assets/reacher_7links.xml rename to alr_envs/alr/mujoco/reacher/assets/reacher_7links.xml diff --git a/alr_envs/mujoco/reacher/balancing.py b/alr_envs/alr/mujoco/reacher/balancing.py similarity index 100% rename from alr_envs/mujoco/reacher/balancing.py rename to alr_envs/alr/mujoco/reacher/balancing.py diff --git a/alr_envs/classic_control/__init__.py b/alr_envs/classic_control/__init__.py deleted file mode 100644 index 8d95b6a..0000000 --- a/alr_envs/classic_control/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from alr_envs.classic_control.hole_reacher.hole_reacher import HoleReacherEnv -from alr_envs.classic_control.viapoint_reacher.viapoint_reacher import ViaPointReacher -from alr_envs.classic_control.simple_reacher.simple_reacher import SimpleReacherEnv diff --git a/alr_envs/dmc/__init__.py b/alr_envs/dmc/__init__.py index b1cf281..17d1f7f 100644 --- a/alr_envs/dmc/__init__.py +++ b/alr_envs/dmc/__init__.py @@ -1,4 +1,385 @@ -from alr_envs.dmc.suite import ball_in_cup -from alr_envs.dmc.suite import reacher -from alr_envs.dmc.suite import cartpole -from alr_envs.dmc.manipulation import reach \ No newline at end of file +from . import manipulation, suite + +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "DetPMP": []} + +from gym.envs.registration import register + +# DeepMind Control Suite (DMC) + +register( + id=f'dmc_ball_in_cup-catch_dmp-v0', + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"ball_in_cup-catch", + "time_limit": 20, + "episode_length": 1000, + "wrappers": [suite.ball_in_cup.MPWrapper], + "mp_kwargs": { + "num_dof": 2, + "num_basis": 5, + "duration": 20, + "learn_goal": True, + "alpha_phase": 2, + "bandwidth_factor": 2, + "policy_type": "motor", + "goal_scale": 0.1, + "policy_kwargs": { + "p_gains": 50, + "d_gains": 1 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("dmc_ball_in_cup-catch_dmp-v0") + +register( + id=f'dmc_ball_in_cup-catch_detpmp-v0', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": f"ball_in_cup-catch", + "time_limit": 20, + "episode_length": 1000, + "wrappers": [suite.ball_in_cup.MPWrapper], + "mp_kwargs": { + "num_dof": 2, + "num_basis": 5, + "duration": 20, + "width": 0.025, + "policy_type": "motor", + "zero_start": True, + "policy_kwargs": { + "p_gains": 50, + "d_gains": 1 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("dmc_ball_in_cup-catch_detpmp-v0") + +register( + id=f'dmc_reacher-easy_dmp-v0', + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"reacher-easy", + "time_limit": 20, + "episode_length": 1000, + "wrappers": [suite.reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 2, + "num_basis": 5, + "duration": 20, + "learn_goal": True, + "alpha_phase": 2, + "bandwidth_factor": 2, + "policy_type": "motor", + "weights_scale": 50, + "goal_scale": 0.1, + "policy_kwargs": { + "p_gains": 50, + "d_gains": 1 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("dmc_reacher-easy_dmp-v0") + +register( + id=f'dmc_reacher-easy_detpmp-v0', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": f"reacher-easy", + "time_limit": 20, + "episode_length": 1000, + "wrappers": [suite.reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 2, + "num_basis": 5, + "duration": 20, + "width": 0.025, + "policy_type": "motor", + "weights_scale": 0.2, + "zero_start": True, + "policy_kwargs": { + "p_gains": 50, + "d_gains": 1 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("dmc_reacher-easy_detpmp-v0") + +register( + id=f'dmc_reacher-hard_dmp-v0', + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"reacher-hard", + "time_limit": 20, + "episode_length": 1000, + "wrappers": [suite.reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 2, + "num_basis": 5, + "duration": 20, + "learn_goal": True, + "alpha_phase": 2, + "bandwidth_factor": 2, + "policy_type": "motor", + "weights_scale": 50, + "goal_scale": 0.1, + "policy_kwargs": { + "p_gains": 50, + "d_gains": 1 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("dmc_reacher-hard_dmp-v0") + +register( + id=f'dmc_reacher-hard_detpmp-v0', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": f"reacher-hard", + "time_limit": 20, + "episode_length": 1000, + "wrappers": [suite.reacher.MPWrapper], + "mp_kwargs": { + "num_dof": 2, + "num_basis": 5, + "duration": 20, + "width": 0.025, + "policy_type": "motor", + "weights_scale": 0.2, + "zero_start": True, + "policy_kwargs": { + "p_gains": 50, + "d_gains": 1 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("dmc_reacher-hard_detpmp-v0") + +_dmc_cartpole_tasks = ["balance", "balance_sparse", "swingup", "swingup_sparse"] + +for _task in _dmc_cartpole_tasks: + _env_id = f'dmc_cartpole-{_task}_dmp-v0' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"cartpole-{_task}", + # "time_limit": 1, + "camera_id": 0, + "episode_length": 1000, + "wrappers": [suite.cartpole.MPWrapper], + "mp_kwargs": { + "num_dof": 1, + "num_basis": 5, + "duration": 10, + "learn_goal": True, + "alpha_phase": 2, + "bandwidth_factor": 2, + "policy_type": "motor", + "weights_scale": 50, + "goal_scale": 0.1, + "policy_kwargs": { + "p_gains": 10, + "d_gains": 10 + } + } + } + ) + ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(_env_id) + + _env_id = f'dmc_cartpole-{_task}_detpmp-v0' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": f"cartpole-{_task}", + # "time_limit": 1, + "camera_id": 0, + "episode_length": 1000, + "wrappers": [suite.cartpole.MPWrapper], + "mp_kwargs": { + "num_dof": 1, + "num_basis": 5, + "duration": 10, + "width": 0.025, + "policy_type": "motor", + "weights_scale": 0.2, + "zero_start": True, + "policy_kwargs": { + "p_gains": 10, + "d_gains": 10 + } + } + } + ) + ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(_env_id) + +_env_id = f'dmc_cartpole-two_poles_dmp-v0' +register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"cartpole-two_poles", + # "time_limit": 1, + "camera_id": 0, + "episode_length": 1000, + "wrappers": [suite.cartpole.TwoPolesMPWrapper], + "mp_kwargs": { + "num_dof": 1, + "num_basis": 5, + "duration": 10, + "learn_goal": True, + "alpha_phase": 2, + "bandwidth_factor": 2, + "policy_type": "motor", + "weights_scale": 50, + "goal_scale": 0.1, + "policy_kwargs": { + "p_gains": 10, + "d_gains": 10 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(_env_id) + +_env_id = f'dmc_cartpole-two_poles_detpmp-v0' +register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": f"cartpole-two_poles", + # "time_limit": 1, + "camera_id": 0, + "episode_length": 1000, + "wrappers": [suite.cartpole.TwoPolesMPWrapper], + "mp_kwargs": { + "num_dof": 1, + "num_basis": 5, + "duration": 10, + "width": 0.025, + "policy_type": "motor", + "weights_scale": 0.2, + "zero_start": True, + "policy_kwargs": { + "p_gains": 10, + "d_gains": 10 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(_env_id) + +_env_id = f'dmc_cartpole-three_poles_dmp-v0' +register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"cartpole-three_poles", + # "time_limit": 1, + "camera_id": 0, + "episode_length": 1000, + "wrappers": [suite.cartpole.ThreePolesMPWrapper], + "mp_kwargs": { + "num_dof": 1, + "num_basis": 5, + "duration": 10, + "learn_goal": True, + "alpha_phase": 2, + "bandwidth_factor": 2, + "policy_type": "motor", + "weights_scale": 50, + "goal_scale": 0.1, + "policy_kwargs": { + "p_gains": 10, + "d_gains": 10 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append(_env_id) + +_env_id = f'dmc_cartpole-three_poles_detpmp-v0' +register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": f"cartpole-three_poles", + # "time_limit": 1, + "camera_id": 0, + "episode_length": 1000, + "wrappers": [suite.cartpole.ThreePolesMPWrapper], + "mp_kwargs": { + "num_dof": 1, + "num_basis": 5, + "duration": 10, + "width": 0.025, + "policy_type": "motor", + "weights_scale": 0.2, + "zero_start": True, + "policy_kwargs": { + "p_gains": 10, + "d_gains": 10 + } + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(_env_id) + +# DeepMind Manipulation + +register( + id=f'dmc_manipulation-reach_site_dmp-v0', + entry_point='alr_envs.utils.make_env_helpers:make_dmp_env_helper', + # max_episode_steps=1, + kwargs={ + "name": f"manipulation-reach_site_features", + # "time_limit": 1, + "episode_length": 250, + "wrappers": [manipulation.reach_site.MPWrapper], + "mp_kwargs": { + "num_dof": 9, + "num_basis": 5, + "duration": 10, + "learn_goal": True, + "alpha_phase": 2, + "bandwidth_factor": 2, + "policy_type": "velocity", + "weights_scale": 50, + "goal_scale": 0.1, + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DMP"].append("dmc_manipulation-reach_site_dmp-v0") + +register( + id=f'dmc_manipulation-reach_site_detpmp-v0', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": f"manipulation-reach_site_features", + # "time_limit": 1, + "episode_length": 250, + "wrappers": [manipulation.reach_site.MPWrapper], + "mp_kwargs": { + "num_dof": 9, + "num_basis": 5, + "duration": 10, + "width": 0.025, + "policy_type": "velocity", + "weights_scale": 0.2, + "zero_start": True, + } + } +) +ALL_DEEPMIND_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("dmc_manipulation-reach_site_detpmp-v0") diff --git a/alr_envs/utils/dmc_wrapper.py b/alr_envs/dmc/dmc_wrapper.py similarity index 100% rename from alr_envs/utils/dmc_wrapper.py rename to alr_envs/dmc/dmc_wrapper.py diff --git a/alr_envs/dmc/manipulation/__init__.py b/alr_envs/dmc/manipulation/__init__.py index 5d17d4d..f3a4147 100644 --- a/alr_envs/dmc/manipulation/__init__.py +++ b/alr_envs/dmc/manipulation/__init__.py @@ -1 +1 @@ -from alr_envs.dmc.manipulation import reach +from . import reach_site diff --git a/alr_envs/dmc/manipulation/reach/__init__.py b/alr_envs/dmc/manipulation/reach_site/__init__.py similarity index 100% rename from alr_envs/dmc/manipulation/reach/__init__.py rename to alr_envs/dmc/manipulation/reach_site/__init__.py diff --git a/alr_envs/dmc/manipulation/reach/mp_wrapper.py b/alr_envs/dmc/manipulation/reach_site/mp_wrapper.py similarity index 100% rename from alr_envs/dmc/manipulation/reach/mp_wrapper.py rename to alr_envs/dmc/manipulation/reach_site/mp_wrapper.py diff --git a/alr_envs/dmc/suite/__init__.py b/alr_envs/dmc/suite/__init__.py index f889cad..7d206fc 100644 --- a/alr_envs/dmc/suite/__init__.py +++ b/alr_envs/dmc/suite/__init__.py @@ -1 +1 @@ -from alr_envs.dmc.suite import cartpole, ball_in_cup, reacher +from . import cartpole, ball_in_cup, reacher diff --git a/alr_envs/meta/__init__.py b/alr_envs/meta/__init__.py index b2482ee..8cf1784 100644 --- a/alr_envs/meta/__init__.py +++ b/alr_envs/meta/__init__.py @@ -1 +1,114 @@ -from alr_envs.meta import goal_and_object_change, goal_and_endeffector_change, goal_change, object_change +from gym import register + +from . import goal_object_change_mp_wrapper, goal_change_mp_wrapper, goal_endeffector_change_mp_wrapper, \ + object_change_mp_wrapper + +ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "DetPMP": []} + +# MetaWorld + +_goal_change_envs = ["assembly-v2", "pick-out-of-hole-v2", "plate-slide-v2", "plate-slide-back-v2"] +for _task in _goal_change_envs: + task_id_split = _task.split("-") + name = "".join([s.capitalize() for s in task_id_split[:-1]]) + _env_id = f'{name}DetPMP-{task_id_split[-1]}' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": _task, + "wrappers": [goal_change_mp_wrapper.MPWrapper], + "mp_kwargs": { + "num_dof": 4, + "num_basis": 5, + "duration": 6.25, + "post_traj_time": 0, + "width": 0.025, + "zero_start": True, + "policy_type": "metaworld", + } + } + ) + ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(_env_id) + +_object_change_envs = ["bin-picking-v2", "hammer-v2", "sweep-into-v2"] +for _task in _object_change_envs: + task_id_split = _task.split("-") + name = "".join([s.capitalize() for s in task_id_split[:-1]]) + _env_id = f'{name}DetPMP-{task_id_split[-1]}' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": _task, + "wrappers": [object_change_mp_wrapper.MPWrapper], + "mp_kwargs": { + "num_dof": 4, + "num_basis": 5, + "duration": 6.25, + "post_traj_time": 0, + "width": 0.025, + "zero_start": True, + "policy_type": "metaworld", + } + } + ) + ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(_env_id) + +_goal_and_object_change_envs = ["box-close-v2", "button-press-v2", "button-press-wall-v2", "button-press-topdown-v2", + "button-press-topdown-wall-v2", "coffee-button-v2", "coffee-pull-v2", + "coffee-push-v2", "dial-turn-v2", "disassemble-v2", "door-close-v2", + "door-lock-v2", "door-open-v2", "door-unlock-v2", "hand-insert-v2", + "drawer-close-v2", "drawer-open-v2", "faucet-open-v2", "faucet-close-v2", + "handle-press-side-v2", "handle-press-v2", "handle-pull-side-v2", + "handle-pull-v2", "lever-pull-v2", "peg-insert-side-v2", "pick-place-wall-v2", + "reach-v2", "push-back-v2", "push-v2", "pick-place-v2", "peg-unplug-side-v2", + "soccer-v2", "stick-push-v2", "stick-pull-v2", "push-wall-v2", "reach-wall-v2", + "shelf-place-v2", "sweep-v2", "window-open-v2", "window-close-v2" + ] +for _task in _goal_and_object_change_envs: + task_id_split = _task.split("-") + name = "".join([s.capitalize() for s in task_id_split[:-1]]) + _env_id = f'{name}DetPMP-{task_id_split[-1]}' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": _task, + "wrappers": [goal_object_change_mp_wrapper.MPWrapper], + "mp_kwargs": { + "num_dof": 4, + "num_basis": 5, + "duration": 6.25, + "post_traj_time": 0, + "width": 0.025, + "zero_start": True, + "policy_type": "metaworld", + } + } + ) + ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(_env_id) + +_goal_and_endeffector_change_envs = ["basketball-v2"] +for _task in _goal_and_endeffector_change_envs: + task_id_split = _task.split("-") + name = "".join([s.capitalize() for s in task_id_split[:-1]]) + _env_id = f'{name}DetPMP-{task_id_split[-1]}' + register( + id=_env_id, + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": _task, + "wrappers": [goal_endeffector_change_mp_wrapper.MPWrapper], + "mp_kwargs": { + "num_dof": 4, + "num_basis": 5, + "duration": 6.25, + "post_traj_time": 0, + "width": 0.025, + "zero_start": True, + "policy_type": "metaworld", + } + } + ) + ALL_METAWORLD_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append(_env_id) diff --git a/alr_envs/meta/goal_change.py b/alr_envs/meta/goal_change_mp_wrapper.py similarity index 100% rename from alr_envs/meta/goal_change.py rename to alr_envs/meta/goal_change_mp_wrapper.py diff --git a/alr_envs/meta/goal_and_endeffector_change.py b/alr_envs/meta/goal_endeffector_change_mp_wrapper.py similarity index 100% rename from alr_envs/meta/goal_and_endeffector_change.py rename to alr_envs/meta/goal_endeffector_change_mp_wrapper.py diff --git a/alr_envs/meta/goal_and_object_change.py b/alr_envs/meta/goal_object_change_mp_wrapper.py similarity index 100% rename from alr_envs/meta/goal_and_object_change.py rename to alr_envs/meta/goal_object_change_mp_wrapper.py diff --git a/alr_envs/meta/object_change.py b/alr_envs/meta/object_change_mp_wrapper.py similarity index 100% rename from alr_envs/meta/object_change.py rename to alr_envs/meta/object_change_mp_wrapper.py diff --git a/alr_envs/mujoco/__init__.py b/alr_envs/mujoco/__init__.py deleted file mode 100644 index d86e772..0000000 --- a/alr_envs/mujoco/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from alr_envs.mujoco.reacher.alr_reacher import ALRReacherEnv -from alr_envs.mujoco.reacher.balancing import BalancingEnv -from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup import ALRBallInACupEnv -from alr_envs.mujoco.ball_in_a_cup.biac_pd import ALRBallInACupPDEnv diff --git a/alr_envs/mujoco/ball_in_a_cup/assets/ball-in-a-cup_base.xml b/alr_envs/mujoco/ball_in_a_cup/assets/ball-in-a-cup_base.xml deleted file mode 100644 index b534205..0000000 --- a/alr_envs/mujoco/ball_in_a_cup/assets/ball-in-a-cup_base.xml +++ /dev/null @@ -1,366 +0,0 @@ - - - diff --git a/alr_envs/mujoco/gym_table_tennis/envs/MUJOCO_LOG.TXT b/alr_envs/mujoco/gym_table_tennis/envs/MUJOCO_LOG.TXT deleted file mode 100644 index 91c2162..0000000 --- a/alr_envs/mujoco/gym_table_tennis/envs/MUJOCO_LOG.TXT +++ /dev/null @@ -1,3 +0,0 @@ -Mon Jan 25 15:45:30 2021 -ERROR: GLEW initalization error: Missing GL version - diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_dist_link_convex.stl b/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_dist_link_convex.stl deleted file mode 100644 index 3b05c27..0000000 Binary files a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_dist_link_convex.stl and /dev/null differ diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p2.stl b/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p2.stl deleted file mode 100644 index 7b2f001..0000000 Binary files a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_finger_prox_link_convex_decomposition_p2.stl and /dev/null differ diff --git a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_fine.stl b/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_fine.stl deleted file mode 100644 index 0a986fa..0000000 Binary files a/alr_envs/mujoco/gym_table_tennis/envs/assets/meshes/bhand_palm_fine.stl and /dev/null differ diff --git a/alr_envs/mujoco/meshes/wam/elbow_link_fine.stl b/alr_envs/mujoco/meshes/wam/elbow_link_fine.stl deleted file mode 100755 index f6a1515..0000000 Binary files a/alr_envs/mujoco/meshes/wam/elbow_link_fine.stl and /dev/null differ diff --git a/alr_envs/mujoco/meshes/wam/wrist_palm_link_fine.stl b/alr_envs/mujoco/meshes/wam/wrist_palm_link_fine.stl deleted file mode 100755 index f6b41ad..0000000 Binary files a/alr_envs/mujoco/meshes/wam/wrist_palm_link_fine.stl and /dev/null differ diff --git a/alr_envs/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p1.stl b/alr_envs/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p1.stl deleted file mode 100755 index c36f88f..0000000 Binary files a/alr_envs/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p1.stl and /dev/null differ diff --git a/alr_envs/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p2.stl b/alr_envs/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p2.stl deleted file mode 100755 index d00cac1..0000000 Binary files a/alr_envs/mujoco/meshes/wam/wrist_pitch_link_convex_decomposition_p2.stl and /dev/null differ diff --git a/alr_envs/mujoco/meshes/wam/wrist_pitch_link_fine.stl b/alr_envs/mujoco/meshes/wam/wrist_pitch_link_fine.stl deleted file mode 100755 index 13d2f73..0000000 Binary files a/alr_envs/mujoco/meshes/wam/wrist_pitch_link_fine.stl and /dev/null differ diff --git a/alr_envs/mujoco/meshes/wam/wrist_yaw_link_fine.stl b/alr_envs/mujoco/meshes/wam/wrist_yaw_link_fine.stl deleted file mode 100755 index 0d95239..0000000 Binary files a/alr_envs/mujoco/meshes/wam/wrist_yaw_link_fine.stl and /dev/null differ diff --git a/alr_envs/mujoco/reacher/alr_reacher.py b/alr_envs/mujoco/reacher/alr_reacher.py deleted file mode 100644 index e27e069..0000000 --- a/alr_envs/mujoco/reacher/alr_reacher.py +++ /dev/null @@ -1,88 +0,0 @@ -import os - -import numpy as np -from gym import utils -from gym.envs.mujoco import MujocoEnv - -import alr_envs.utils.utils as alr_utils - - -class ALRReacherEnv(MujocoEnv, utils.EzPickle): - def __init__(self, steps_before_reward=200, n_links=5, balance=False): - utils.EzPickle.__init__(**locals()) - - self._steps = 0 - self.steps_before_reward = steps_before_reward - self.n_links = n_links - - self.balance = balance - self.balance_weight = 1.0 - - self.reward_weight = 1 - if steps_before_reward == 200: - self.reward_weight = 200 - elif steps_before_reward == 50: - self.reward_weight = 50 - - if n_links == 5: - file_name = 'reacher_5links.xml' - elif n_links == 7: - file_name = 'reacher_7links.xml' - else: - raise ValueError(f"Invalid number of links {n_links}, only 5 or 7 allowed.") - - MujocoEnv.__init__(self, os.path.join(os.path.dirname(__file__), "assets", file_name), 2) - - def step(self, a): - self._steps += 1 - - reward_dist = 0.0 - angular_vel = 0.0 - reward_balance = 0.0 - if self._steps >= self.steps_before_reward: - vec = self.get_body_com("fingertip") - self.get_body_com("target") - reward_dist -= self.reward_weight * np.linalg.norm(vec) - angular_vel -= np.linalg.norm(self.sim.data.qvel.flat[:self.n_links]) - reward_ctrl = - np.square(a).sum() - - if self.balance: - reward_balance -= self.balance_weight * np.abs( - alr_utils.angle_normalize(np.sum(self.sim.data.qpos.flat[:self.n_links]), type="rad")) - - reward = reward_dist + reward_ctrl + angular_vel + reward_balance - 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, - velocity=angular_vel, reward_balance=reward_balance, - end_effector=self.get_body_com("fingertip").copy(), - goal=self.goal if hasattr(self, "goal") else None) - - def viewer_setup(self): - self.viewer.cam.trackbodyid = 0 - - def reset_model(self): - qpos = self.np_random.uniform(low=-0.1, high=0.1, size=self.model.nq) + self.init_qpos - while True: - self.goal = self.np_random.uniform(low=-self.n_links / 10, high=self.n_links / 10, size=2) - if np.linalg.norm(self.goal) < self.n_links / 10: - break - qpos[-2:] = self.goal - qvel = self.init_qvel + self.np_random.uniform(low=-.005, high=.005, size=self.model.nv) - qvel[-2:] = 0 - self.set_state(qpos, qvel) - self._steps = 0 - - return self._get_obs() - - def _get_obs(self): - theta = self.sim.data.qpos.flat[:self.n_links] - return np.concatenate([ - np.cos(theta), - np.sin(theta), - self.sim.data.qpos.flat[self.n_links:], # this is goal position - self.sim.data.qvel.flat[:self.n_links], # this is angular velocity - self.get_body_com("fingertip") - self.get_body_com("target"), - # self.get_body_com("target"), # only return target to make problem harder - [self._steps], - ]) diff --git a/alr_envs/open_ai/__init__.py b/alr_envs/open_ai/__init__.py index 1e531cf..b9e53b4 100644 --- a/alr_envs/open_ai/__init__.py +++ b/alr_envs/open_ai/__init__.py @@ -1,3 +1,130 @@ -from alr_envs.open_ai.mujoco import reacher_v2 -from alr_envs.open_ai.robotics import fetch -from alr_envs.open_ai.classic_control import continuous_mountain_car \ No newline at end of file +from gym import register +from gym.wrappers import FlattenObservation + +from . import classic_control, mujoco, robotics + +ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "DetPMP": []} + +# Open AI +# Classic Control +register( + id='ContinuousMountainCarDetPMP-v0', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": "gym.envs.classic_control:MountainCarContinuous-v0", + "wrappers": [classic_control.continuous_mountain_car.MPWrapper], + "mp_kwargs": { + "num_dof": 1, + "num_basis": 4, + "duration": 2, + "post_traj_time": 0, + "width": 0.02, + "zero_start": True, + "policy_type": "motor", + "policy_kwargs": { + "p_gains": 1., + "d_gains": 1. + } + } + } +) +ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("ContinuousMountainCarDetPMP-v0") + +register( + id='ReacherDetPMP-v2', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": "gym.envs.mujoco:Reacher-v2", + "wrappers": [mujoco.reacher_v2.MPWrapper], + "mp_kwargs": { + "num_dof": 2, + "num_basis": 6, + "duration": 1, + "post_traj_time": 0, + "width": 0.02, + "zero_start": True, + "policy_type": "motor", + "policy_kwargs": { + "p_gains": .6, + "d_gains": .075 + } + } + } +) +ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("ReacherDetPMP-v2") + +register( + id='FetchSlideDenseDetPMP-v1', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": "gym.envs.robotics:FetchSlideDense-v1", + "wrappers": [FlattenObservation, robotics.fetch.MPWrapper], + "mp_kwargs": { + "num_dof": 4, + "num_basis": 5, + "duration": 2, + "post_traj_time": 0, + "width": 0.02, + "zero_start": True, + "policy_type": "position" + } + } +) +ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("FetchSlideDenseDetPMP-v1") + +register( + id='FetchSlideDetPMP-v1', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": "gym.envs.robotics:FetchSlide-v1", + "wrappers": [FlattenObservation, robotics.fetch.MPWrapper], + "mp_kwargs": { + "num_dof": 4, + "num_basis": 5, + "duration": 2, + "post_traj_time": 0, + "width": 0.02, + "zero_start": True, + "policy_type": "position" + } + } +) +ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("FetchSlideDetPMP-v1") + +register( + id='FetchReachDenseDetPMP-v1', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": "gym.envs.robotics:FetchReachDense-v1", + "wrappers": [FlattenObservation, robotics.fetch.MPWrapper], + "mp_kwargs": { + "num_dof": 4, + "num_basis": 5, + "duration": 2, + "post_traj_time": 0, + "width": 0.02, + "zero_start": True, + "policy_type": "position" + } + } +) +ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("FetchReachDenseDetPMP-v1") + +register( + id='FetchReachDetPMP-v1', + entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env_helper', + kwargs={ + "name": "gym.envs.robotics:FetchReach-v1", + "wrappers": [FlattenObservation, robotics.fetch.MPWrapper], + "mp_kwargs": { + "num_dof": 4, + "num_basis": 5, + "duration": 2, + "post_traj_time": 0, + "width": 0.02, + "zero_start": True, + "policy_type": "position" + } + } +) +ALL_GYM_MOTION_PRIMITIVE_ENVIRONMENTS["DetPMP"].append("FetchReachDetPMP-v1") diff --git a/alr_envs/open_ai/classic_control/__init__.py b/alr_envs/open_ai/classic_control/__init__.py index e69de29..b998494 100644 --- a/alr_envs/open_ai/classic_control/__init__.py +++ b/alr_envs/open_ai/classic_control/__init__.py @@ -0,0 +1 @@ +from . import continuous_mountain_car \ No newline at end of file diff --git a/alr_envs/open_ai/mujoco/__init__.py b/alr_envs/open_ai/mujoco/__init__.py index e69de29..3082d19 100644 --- a/alr_envs/open_ai/mujoco/__init__.py +++ b/alr_envs/open_ai/mujoco/__init__.py @@ -0,0 +1 @@ +from . import reacher_v2 diff --git a/alr_envs/open_ai/robotics/__init__.py b/alr_envs/open_ai/robotics/__init__.py index e69de29..13c65b3 100644 --- a/alr_envs/open_ai/robotics/__init__.py +++ b/alr_envs/open_ai/robotics/__init__.py @@ -0,0 +1 @@ +from . import fetch \ No newline at end of file diff --git a/alr_envs/utils/__init__.py b/alr_envs/utils/__init__.py index b811354..bb4b0bc 100644 --- a/alr_envs/utils/__init__.py +++ b/alr_envs/utils/__init__.py @@ -47,7 +47,7 @@ def make_dmc( task_kwargs['time_limit'] = time_limit register( id=env_id, - entry_point='alr_envs.utils.dmc_wrapper:DMCWrapper', + entry_point='alr_envs.dmc.dmc_wrapper:DMCWrapper', kwargs=dict( domain_name=domain_name, task_name=task_name, diff --git a/alr_envs/utils/make_env_helpers.py b/alr_envs/utils/make_env_helpers.py index 755b8ce..fc73b05 100644 --- a/alr_envs/utils/make_env_helpers.py +++ b/alr_envs/utils/make_env_helpers.py @@ -76,7 +76,7 @@ def make(env_id: str, seed, **kwargs): else: # DMC - from alr_envs.utils import make_dmc + from alr_envs import make_dmc env = make_dmc(env_id, seed=seed, **kwargs) assert env.base_step_limit == env.spec.max_episode_steps, \ @@ -123,11 +123,11 @@ def make_dmp_env(env_id: str, wrappers: Iterable, seed=1, mp_kwargs={}, **kwargs Returns: DMP wrapped gym env """ - verify_time_limit(mp_kwargs.get("duration", None), kwargs.get("time_limit", None)) + _verify_time_limit(mp_kwargs.get("duration", None), kwargs.get("time_limit", None)) _env = _make_wrapped_env(env_id=env_id, wrappers=wrappers, seed=seed, **kwargs) - verify_dof(_env, mp_kwargs.get("num_dof")) + _verify_dof(_env, mp_kwargs.get("num_dof")) return DmpWrapper(_env, **mp_kwargs) @@ -143,11 +143,11 @@ def make_detpmp_env(env_id: str, wrappers: Iterable, seed=1, mp_kwargs={}, **kwa Returns: DMP wrapped gym env """ - verify_time_limit(mp_kwargs.get("duration", None), kwargs.get("time_limit", None)) + _verify_time_limit(mp_kwargs.get("duration", None), kwargs.get("time_limit", None)) _env = _make_wrapped_env(env_id=env_id, wrappers=wrappers, seed=seed, **kwargs) - verify_dof(_env, mp_kwargs.get("num_dof")) + _verify_dof(_env, mp_kwargs.get("num_dof")) return DetPMPWrapper(_env, **mp_kwargs) @@ -191,14 +191,7 @@ def make_detpmp_env_helper(**kwargs): mp_kwargs=kwargs.pop("mp_kwargs"), **kwargs) -def make_contextual_env(env_id, context, seed, rank): - env = make(env_id, seed + rank, context=context) - # env = gym.make(env_id, context=context) - # env.seed(seed + rank) - return lambda: env - - -def verify_time_limit(mp_time_limit: Union[None, float], env_time_limit: Union[None, float]): +def _verify_time_limit(mp_time_limit: Union[None, float], env_time_limit: Union[None, float]): """ When using DMC check if a manually specified time limit matches the trajectory duration the MP receives. Mostly, the time_limit for DMC is not specified and the default values from DMC are taken. @@ -218,7 +211,7 @@ def verify_time_limit(mp_time_limit: Union[None, float], env_time_limit: Union[N f"the duration of {mp_time_limit}s for the MP." -def verify_dof(base_env: gym.Env, dof: int): +def _verify_dof(base_env: gym.Env, dof: int): action_shape = np.prod(base_env.action_space.shape) assert dof == action_shape, \ f"The specified degrees of freedom ('num_dof') {dof} do not match " \ diff --git a/alr_envs/utils/mp_env_async_sampler.py b/alr_envs/utils/mp_env_async_sampler.py deleted file mode 100644 index b24e908..0000000 --- a/alr_envs/utils/mp_env_async_sampler.py +++ /dev/null @@ -1,122 +0,0 @@ -import gym -from gym.vector.async_vector_env import AsyncVectorEnv -import numpy as np -from _collections import defaultdict - -from alr_envs.utils.make_env_helpers import make_rank - - -def split_array(ary, size): - n_samples = len(ary) - if n_samples < size: - tmp = np.zeros((size, ary.shape[1])) - tmp[0:n_samples] = ary - return [tmp] - elif n_samples == size: - return [ary] - else: - repeat = int(np.ceil(n_samples / size)) - split = [k * size for k in range(1, repeat)] - sub_arys = np.split(ary, split) - - if n_samples % size != 0: - tmp = np.zeros_like(sub_arys[0]) - last = sub_arys[-1] - tmp[0: len(last)] = last - sub_arys[-1] = tmp - - return sub_arys - - -def _flatten_list(l): - assert isinstance(l, (list, tuple)) - assert len(l) > 0 - assert all([len(l_) > 0 for l_ in l]) - - return [l__ for l_ in l for l__ in l_] - - -class DummyDist: - def __init__(self, dim): - self.dim = dim - - def sample(self, contexts): - contexts = np.atleast_2d(contexts) - n_samples = contexts.shape[0] - return np.random.normal(size=(n_samples, self.dim)), contexts - - -class AlrMpEnvSampler: - """ - An asynchronous sampler for non contextual MPWrapper environments. A sampler object can be called with a set of - parameters and returns the corresponding final obs, rewards, dones and info dicts. - """ - - def __init__(self, env_id, num_envs, seed=0, **env_kwargs): - self.num_envs = num_envs - self.env = AsyncVectorEnv([make_rank(env_id, seed, i, **env_kwargs) for i in range(num_envs)]) - - def __call__(self, params): - params = np.atleast_2d(params) - n_samples = params.shape[0] - split_params = split_array(params, self.num_envs) - - vals = defaultdict(list) - for p in split_params: - self.env.reset() - obs, reward, done, info = self.env.step(p) - vals['obs'].append(obs) - vals['reward'].append(reward) - vals['done'].append(done) - vals['info'].append(info) - - # do not return values above threshold - return np.vstack(vals['obs'])[:n_samples], np.hstack(vals['reward'])[:n_samples], \ - _flatten_list(vals['done'])[:n_samples], _flatten_list(vals['info'])[:n_samples] - - -class AlrContextualMpEnvSampler: - """ - An asynchronous sampler for contextual MPWrapper environments. A sampler object can be called with a set of - parameters and returns the corresponding final obs, rewards, dones and info dicts. - """ - - def __init__(self, env_id, num_envs, seed=0, **env_kwargs): - self.num_envs = num_envs - self.env = AsyncVectorEnv([make_env(env_id, seed, i, **env_kwargs) for i in range(num_envs)]) - - def __call__(self, dist, n_samples): - repeat = int(np.ceil(n_samples / self.env.num_envs)) - vals = defaultdict(list) - - obs = self.env.reset() - for i in range(repeat): - vals['obs'].append(obs) - new_samples, new_contexts = dist.sample(obs) - vals['new_samples'].append(new_samples) - - obs, reward, done, info = self.env.step(new_samples) - - vals['reward'].append(reward) - vals['done'].append(done) - vals['info'].append(info) - - # do not return values above threshold - return np.vstack(vals['new_samples'])[:n_samples], \ - np.vstack(vals['obs'])[:n_samples], np.hstack(vals['reward'])[:n_samples], \ - _flatten_list(vals['done'])[:n_samples], _flatten_list(vals['info'])[:n_samples] - - -if __name__ == "__main__": - env_name = "alr_envs:HoleReacherDetPMP-v1" - n_cpu = 8 - dim = 25 - n_samples = 10 - - sampler = AlrMpEnvSampler(env_name, num_envs=n_cpu) - - thetas = np.random.randn(n_samples, dim) # usually form a search distribution - - _, rewards, __, ___ = sampler(thetas) - - print(rewards) diff --git a/setup.py b/setup.py index 55a1a95..beb2095 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,7 @@ from setuptools import setup setup( name='alr_envs', version='0.0.1', - packages=['alr_envs', 'alr_envs.classic_control', 'alr_envs.open_ai', 'alr_envs.mujoco', 'alr_envs.dmc', - 'alr_envs.utils'], + packages=['alr_envs', 'alr_envs.alr', 'alr_envs.open_ai', 'alr_envs.dmc', 'alr_envs.meta', 'alr_envs.utils'], install_requires=[ 'gym', 'PyQt5',