fancy_gym/alr_envs/__init__.py

481 lines
12 KiB
Python
Raw Normal View History

import numpy as np
2020-08-28 18:31:06 +02:00
from gym.envs.registration import register
2020-11-03 11:26:06 +01:00
from alr_envs.stochastic_search.functions.f_rosenbrock import Rosenbrock
2021-05-12 09:52:25 +02:00
# from alr_envs.utils.mps.dmp_wrapper import DmpWrapper
# Mujoco
2020-11-03 11:26:06 +01:00
2020-08-28 18:31:06 +02:00
register(
id='ALRReacher-v0',
entry_point='alr_envs.mujoco:ALRReacherEnv',
2020-09-19 17:47:20 +02:00
max_episode_steps=200,
kwargs={
"steps_before_reward": 0,
2020-09-22 17:41:25 +02:00
"n_links": 5,
"balance": False,
2020-09-22 17:41:25 +02:00
}
)
register(
id='ALRReacherSparse-v0',
2020-09-26 15:07:42 +02:00
entry_point='alr_envs.mujoco:ALRReacherEnv',
max_episode_steps=200,
2020-09-26 15:07:42 +02:00
kwargs={
"steps_before_reward": 200,
2020-09-26 15:07:42 +02:00
"n_links": 5,
"balance": False,
2020-09-26 15:07:42 +02:00
}
)
2020-09-22 17:41:25 +02:00
register(
id='ALRReacherSparseBalanced-v0',
2020-09-22 17:41:25 +02:00
entry_point='alr_envs.mujoco:ALRReacherEnv',
max_episode_steps=200,
kwargs={
"steps_before_reward": 200,
"n_links": 5,
"balance": True,
2020-09-19 17:47:20 +02:00
}
)
register(
id='ALRLongReacher-v0',
2020-09-19 17:47:20 +02:00
entry_point='alr_envs.mujoco:ALRReacherEnv',
max_episode_steps=200,
2020-09-19 17:47:20 +02:00
kwargs={
"steps_before_reward": 0,
"n_links": 7,
"balance": False,
2020-09-19 17:47:20 +02:00
}
)
register(
id='ALRLongReacherSparse-v0',
2020-09-19 17:47:20 +02:00
entry_point='alr_envs.mujoco:ALRReacherEnv',
max_episode_steps=200,
kwargs={
"steps_before_reward": 200,
2020-09-19 17:47:20 +02:00
"n_links": 7,
"balance": False,
2020-09-19 17:47:20 +02:00
}
)
register(
id='ALRLongReacherSparseBalanced-v0',
2020-09-19 17:47:20 +02:00
entry_point='alr_envs.mujoco:ALRReacherEnv',
max_episode_steps=200,
kwargs={
"steps_before_reward": 200,
2020-09-19 17:47:20 +02:00
"n_links": 7,
"balance": True,
2020-09-19 17:47:20 +02:00
}
)
## Balancing Reacher
register(
id='Balancing-v0',
entry_point='alr_envs.mujoco:BalancingEnv',
max_episode_steps=200,
kwargs={
"n_links": 5,
}
)
2021-04-23 12:47:55 +02:00
register(
id='ALRBallInACupSimple-v0',
entry_point='alr_envs.mujoco:ALRBallInACupEnv',
max_episode_steps=4000,
2021-06-23 18:23:37 +02:00
kwargs={
"simplified": True,
"reward_type": "no_context",
}
)
register(
id='ALRBallInACupPDSimple-v0',
entry_point='alr_envs.mujoco:ALRBallInACupPDEnv',
max_episode_steps=4000,
2021-04-23 12:47:55 +02:00
kwargs={
"simplified": True,
"reward_type": "no_context"
}
)
2021-06-24 18:34:39 +02:00
register(
id='ALRBallInACupPD-v0',
entry_point='alr_envs.mujoco:ALRBallInACupPDEnv',
max_episode_steps=4000,
kwargs={
"simplified": False,
"reward_type": "no_context"
}
)
2021-04-23 11:37:42 +02:00
register(
2021-04-23 12:16:19 +02:00
id='ALRBallInACup-v0',
2021-04-23 11:37:42 +02:00
entry_point='alr_envs.mujoco:ALRBallInACupEnv',
max_episode_steps=4000,
kwargs={
2021-04-23 12:47:55 +02:00
"reward_type": "no_context"
2021-04-23 11:37:42 +02:00
}
)
register(
id='ALRBallInACupGoal-v0',
entry_point='alr_envs.mujoco:ALRBallInACupEnv',
max_episode_steps=4000,
kwargs={
"reward_type": "contextual_goal"
}
)
# Classic control
2020-09-19 17:47:20 +02:00
## Simple Reacher
2020-08-28 18:31:06 +02:00
register(
id='SimpleReacher-v0',
entry_point='alr_envs.classic_control:SimpleReacherEnv',
max_episode_steps=200,
2020-08-28 18:31:06 +02:00
kwargs={
"n_links": 2,
}
)
2021-05-07 09:51:53 +02:00
register(
id='SimpleReacher-v1',
entry_point='alr_envs.classic_control:SimpleReacherEnv',
max_episode_steps=200,
kwargs={
"n_links": 2,
"random_start": False
}
)
2021-05-10 12:17:52 +02:00
register(
id='LongSimpleReacher-v0',
entry_point='alr_envs.classic_control:SimpleReacherEnv',
2021-05-10 12:17:52 +02:00
max_episode_steps=200,
kwargs={
"n_links": 5,
2021-05-10 12:17:52 +02:00
}
)
register(
id='LongSimpleReacher-v1',
entry_point='alr_envs.classic_control:SimpleReacherEnv',
2021-05-10 12:17:52 +02:00
max_episode_steps=200,
kwargs={
"n_links": 5,
2021-05-10 12:17:52 +02:00
"random_start": False
}
)
## Viapoint Reacher
2021-03-26 15:32:50 +01:00
register(
id='ViaPointReacher-v0',
entry_point='alr_envs.classic_control.viapoint_reacher:ViaPointReacher',
2021-03-26 15:32:50 +01:00
max_episode_steps=200,
kwargs={
"n_links": 5,
"allow_self_collision": False,
"collision_penalty": 1000
2021-03-26 15:32:50 +01:00
}
)
## Hole Reacher
register(
id='HoleReacher-v0',
entry_point='alr_envs.classic_control.hole_reacher:HoleReacherEnv',
max_episode_steps=200,
kwargs={
"n_links": 5,
2021-05-18 15:27:08 +02:00
"random_start": True,
"allow_self_collision": False,
"allow_wall_collision": False,
"hole_width": None,
"hole_depth": 1,
"hole_x": None,
2021-06-16 10:29:38 +02:00
"collision_penalty": 1000,
2020-08-28 18:31:06 +02:00
}
)
2020-11-03 11:26:06 +01:00
register(
id='HoleReacher-v1',
entry_point='alr_envs.classic_control.hole_reacher:HoleReacherEnv',
2020-11-03 11:26:06 +01:00
max_episode_steps=200,
kwargs={
"n_links": 5,
"random_start": False,
"allow_self_collision": False,
"allow_wall_collision": False,
"hole_width": None,
"hole_depth": 1,
"hole_x": None,
"collision_penalty": 100,
2020-11-03 11:26:06 +01:00
}
)
2021-05-07 09:51:53 +02:00
register(
id='HoleReacher-v2',
entry_point='alr_envs.classic_control.hole_reacher:HoleReacherEnv',
2021-05-07 09:51:53 +02:00
max_episode_steps=200,
kwargs={
"n_links": 5,
"random_start": False,
2021-05-07 09:51:53 +02:00
"allow_self_collision": False,
"allow_wall_collision": False,
"hole_width": 0.25,
"hole_depth": 1,
"hole_x": 2,
2021-06-16 10:29:38 +02:00
"collision_penalty": 1000,
2021-05-07 09:51:53 +02:00
}
)
2021-04-21 10:45:34 +02:00
# MP environments
2021-05-17 17:58:33 +02:00
## Simple Reacher
versions = ["SimpleReacher-v0", "SimpleReacher-v1", "LongSimpleReacher-v0", "LongSimpleReacher-v1"]
for v in versions:
name = v.split("-")
register(
id=f'{name[0]}DMP-{name[1]}',
entry_point='alr_envs.utils.make_env_helpers:make_dmp_env',
# max_episode_steps=1,
kwargs={
2021-05-17 17:58:33 +02:00
"name": f"alr_envs:{v}",
"num_dof": 2 if "long" not in v.lower() else 5,
"num_basis": 5,
"duration": 2,
"alpha_phase": 2,
"learn_goal": True,
"policy_type": "velocity",
"weights_scale": 50,
}
)
2021-05-07 09:51:53 +02:00
register(
id='ViaPointReacherDMP-v0',
2021-05-07 09:51:53 +02:00
entry_point='alr_envs.utils.make_env_helpers:make_dmp_env',
# max_episode_steps=1,
kwargs={
"name": "alr_envs:ViaPointReacher-v0",
"num_dof": 5,
2021-05-07 09:51:53 +02:00
"num_basis": 5,
"duration": 2,
"alpha_phase": 2,
"learn_goal": False,
2021-05-07 09:51:53 +02:00
"policy_type": "velocity",
"weights_scale": 50,
}
)
2021-05-17 17:58:33 +02:00
## Hole Reacher
versions = ["v0", "v1", "v2"]
for v in versions:
register(
id=f'HoleReacherDMP-{v}',
entry_point='alr_envs.utils.make_env_helpers:make_dmp_env',
# max_episode_steps=1,
kwargs={
"name": f"alr_envs:HoleReacher-{v}",
"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
}
)
register(
id=f'HoleReacherDetPMP-{v}',
entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env',
kwargs={
"name": f"alr_envs:HoleReacher-{v}",
"num_dof": 5,
"num_basis": 5,
"duration": 2,
2021-05-27 17:08:26 +02:00
"width": 0.025,
"policy_type": "velocity",
"weights_scale": 0.2,
"zero_start": True
}
)
2021-05-07 09:51:53 +02:00
2021-04-21 10:45:34 +02:00
# TODO: properly add final_pos
register(
id='HoleReacherFixedGoalDMP-v0',
2021-04-21 10:45:34 +02:00
entry_point='alr_envs.utils.make_env_helpers:make_dmp_env',
# max_episode_steps=1,
2021-04-21 10:45:34 +02:00
kwargs={
"name": "alr_envs:HoleReacher-v0",
"num_dof": 5,
"num_basis": 5,
"duration": 2,
"learn_goal": False,
"alpha_phase": 2,
"policy_type": "velocity",
"weights_scale": 50,
"goal_scale": 0.1
}
)
2021-05-17 17:58:33 +02:00
## Ball in Cup
2021-04-23 11:37:42 +02:00
register(
2021-04-23 11:37:42 +02:00
id='ALRBallInACupSimpleDMP-v0',
entry_point='alr_envs.utils.make_env_helpers:make_dmp_env',
kwargs={
2021-04-23 12:47:55 +02:00
"name": "alr_envs:ALRBallInACupSimple-v0",
2021-04-23 11:37:42 +02:00
"num_dof": 3,
"num_basis": 5,
"duration": 3.5,
"post_traj_time": 4.5,
"learn_goal": False,
"alpha_phase": 3,
"bandwidth_factor": 2.5,
"policy_type": "motor",
"weights_scale": 100,
"return_to_start": True,
"p_gains": np.array([4. / 3., 2.4, 2.5, 5. / 3., 2., 2., 1.25]),
"d_gains": np.array([0.0466, 0.12, 0.125, 0.04166, 0.06, 0.06, 0.025])
2021-04-23 11:37:42 +02:00
}
2021-04-21 10:45:34 +02:00
)
2021-04-23 12:16:19 +02:00
register(
id='ALRBallInACupDMP-v0',
entry_point='alr_envs.utils.make_env_helpers:make_dmp_env',
kwargs={
"name": "alr_envs:ALRBallInACup-v0",
"num_dof": 7,
"num_basis": 5,
"duration": 3.5,
"post_traj_time": 4.5,
"learn_goal": False,
"alpha_phase": 3,
"bandwidth_factor": 2.5,
"policy_type": "motor",
"weights_scale": 100,
"return_to_start": True,
"p_gains": np.array([4. / 3., 2.4, 2.5, 5. / 3., 2., 2., 1.25]),
"d_gains": np.array([0.0466, 0.12, 0.125, 0.04166, 0.06, 0.06, 0.025])
2021-04-23 12:16:19 +02:00
}
)
register(
id='ALRBallInACupSimpleDetPMP-v0',
entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env',
kwargs={
"name": "alr_envs:ALRBallInACupSimple-v0",
"num_dof": 3,
"num_basis": 5,
"duration": 3.5,
"post_traj_time": 4.5,
2021-05-27 17:08:26 +02:00
"width": 0.0035,
# "off": -0.05,
"policy_type": "motor",
"weights_scale": 0.2,
"zero_start": True,
"zero_goal": True,
"p_gains": np.array([4./3., 2.4, 2.5, 5./3., 2., 2., 1.25]),
"d_gains": np.array([0.0466, 0.12, 0.125, 0.04166, 0.06, 0.06, 0.025])
}
)
2021-06-23 18:23:37 +02:00
register(
id='ALRBallInACupPDSimpleDetPMP-v0',
entry_point='alr_envs.mujoco.ball_in_a_cup.biac_pd:make_detpmp_env',
kwargs={
"name": "alr_envs:ALRBallInACupPDSimple-v0",
"num_dof": 3,
"num_basis": 5,
"duration": 3.5,
"post_traj_time": 4.5,
"width": 0.0035,
# "off": -0.05,
"policy_type": "motor",
"weights_scale": 0.2,
"zero_start": True,
"zero_goal": True,
"p_gains": np.array([4./3., 2.4, 2.5, 5./3., 2., 2., 1.25]),
"d_gains": np.array([0.0466, 0.12, 0.125, 0.04166, 0.06, 0.06, 0.025])
}
)
2021-06-24 18:34:39 +02:00
register(
id='ALRBallInACupPDDetPMP-v0',
entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env',
kwargs={
"name": "alr_envs:ALRBallInACupPD-v0",
"num_dof": 7,
"num_basis": 5,
"duration": 3.5,
"post_traj_time": 4.5,
"width": 0.0035,
# "off": -0.05,
"policy_type": "motor",
"weights_scale": 0.2,
"zero_start": True,
"zero_goal": True,
"p_gains": np.array([4./3., 2.4, 2.5, 5./3., 2., 2., 1.25]),
"d_gains": np.array([0.0466, 0.12, 0.125, 0.04166, 0.06, 0.06, 0.025])
}
)
register(
id='ALRBallInACupDetPMP-v0',
entry_point='alr_envs.utils.make_env_helpers:make_detpmp_env',
kwargs={
"name": "alr_envs:ALRBallInACupSimple-v0",
"num_dof": 7,
"num_basis": 5,
"duration": 3.5,
"post_traj_time": 4.5,
"width": 0.0035,
"policy_type": "motor",
"weights_scale": 0.2,
"zero_start": True,
"zero_goal": True,
"p_gains": np.array([4./3., 2.4, 2.5, 5./3., 2., 2., 1.25]),
"d_gains": np.array([0.0466, 0.12, 0.125, 0.04166, 0.06, 0.06, 0.025])
}
)
2021-04-21 10:45:34 +02:00
register(
2021-04-23 11:37:42 +02:00
id='ALRBallInACupGoalDMP-v0',
2021-04-23 12:47:55 +02:00
entry_point='alr_envs.utils.make_env_helpers:make_contextual_env',
2021-04-21 10:45:34 +02:00
kwargs={
2021-04-23 11:37:42 +02:00
"name": "alr_envs:ALRBallInACupGoal-v0",
2021-04-23 12:16:19 +02:00
"num_dof": 7,
2021-04-21 10:45:34 +02:00
"num_basis": 5,
2021-04-23 12:16:19 +02:00
"duration": 3.5,
"post_traj_time": 4.5,
2021-04-21 10:45:34 +02:00
"learn_goal": True,
2021-04-23 12:16:19 +02:00
"alpha_phase": 3,
"bandwidth_factor": 2.5,
"policy_type": "motor",
2021-04-21 10:45:34 +02:00
"weights_scale": 50,
"goal_scale": 0.1,
"p_gains": np.array([4. / 3., 2.4, 2.5, 5. / 3., 2., 2., 1.25]),
"d_gains": np.array([0.0466, 0.12, 0.125, 0.04166, 0.06, 0.06, 0.025])
2021-04-21 10:45:34 +02:00
}
)
# BBO functions
2020-11-03 11:26:06 +01:00
for dim in [5, 10, 25, 50, 100]:
register(
id=f'Rosenbrock{dim}-v0',
entry_point='alr_envs.stochastic_search:StochasticSearchEnv',
max_episode_steps=1,
kwargs={
"cost_f": Rosenbrock(dim),
2020-11-03 11:26:06 +01:00
}
)