From 8fc1210f1ec5488a9937f87821c549050fa9f0ac Mon Sep 17 00:00:00 2001 From: ottofabian Date: Sat, 19 Sep 2020 17:47:20 +0200 Subject: [PATCH] some new stuff --- alr_envs/__init__.py | 53 +++++++++++++++++++++- alr_envs/classic_control/simple_reacher.py | 4 +- example.py | 15 ++++-- 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/alr_envs/__init__.py b/alr_envs/__init__.py index 571bc42..12dfa27 100644 --- a/alr_envs/__init__.py +++ b/alr_envs/__init__.py @@ -3,7 +3,58 @@ from gym.envs.registration import register register( id='ALRReacher-v0', entry_point='alr_envs.mujoco:ALRReacherEnv', - max_episode_steps=1000, + max_episode_steps=200, + kwargs={ + "steps_before_reward": 0, + } +) + +register( + id='ALRReacher100-v0', + entry_point='alr_envs.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 100, + } +) + +register( + id='ALRReacher180-v0', + entry_point='alr_envs.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 180, + } +) + +register( + id='ALRReacher7-v0', + entry_point='alr_envs.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 0, + "n_links": 7, + } +) + +register( + id='ALRReacher100_7-v0', + entry_point='alr_envs.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 100, + "n_links": 7, + } +) + +register( + id='ALRReacher180_7-v0', + entry_point='alr_envs.mujoco:ALRReacherEnv', + max_episode_steps=200, + kwargs={ + "steps_before_reward": 180, + "n_links": 7, + } ) register( diff --git a/alr_envs/classic_control/simple_reacher.py b/alr_envs/classic_control/simple_reacher.py index 4d9d930..3a54432 100644 --- a/alr_envs/classic_control/simple_reacher.py +++ b/alr_envs/classic_control/simple_reacher.py @@ -31,7 +31,7 @@ class SimpleReacherEnv(gym.Env): self._angle_velocity = None self.max_torque = 1 # 10 - self.steps_before_reward = 100 + self.steps_before_reward = 180 action_bound = np.ones((self.n_links,)) state_bound = np.hstack([ @@ -69,7 +69,7 @@ class SimpleReacherEnv(gym.Env): def _add_action_noise(self, action: np.ndarray): """ - add unobserved Gaussian Noise N(0,0.5) to the actions + add unobserved Gaussian Noise N(0,0.01) to the actions Args: action: diff --git a/example.py b/example.py index fda066a..fd11c73 100644 --- a/example.py +++ b/example.py @@ -1,15 +1,20 @@ +import time + import gym if __name__ == '__main__': - # env = gym.make('alr_envs:ALRReacher-v0') - env = gym.make('alr_envs:SimpleReacher-v0') + env = gym.make('alr_envs:ALRReacher-v0') + # env = gym.make('alr_envs:SimpleReacher-v0') + # env = gym.make('alr_envs:ALRReacher7-v0') state = env.reset() for i in range(10000): state, reward, done, info = env.step(env.action_space.sample()) - if i % 5 == 0: + if i % 1 == 0: env.render() - if done: - state = env.reset() + # if done: + state = env.reset() + + time.sleep(0.5)