Skip to content

Commit

Permalink
arm training in prog
Browse files Browse the repository at this point in the history
  • Loading branch information
smsong committed Aug 6, 2019
1 parent 334b906 commit 19f4a8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion examples/mytrain_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
# Load walking environment
env = Arm2DVecEnv(args.visualize)
#env = Arm2DVecEnv(visualize=True)
env.reset(verbose=True, logfile='arm_log.txt')
env.reset()
#env.reset(verbose=True, logfile='arm_log.txt')

nb_actions = env.action_space.shape[0]

Expand Down
16 changes: 8 additions & 8 deletions osim/env/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def generate_new_target(self):
radius = random.uniform(0.3, 0.65)
self.target_x = math.cos(theta) * radius
self.target_y = -math.sin(theta) * radius + 0.8
self.target_x = -0.16056636337579086
self.target_y = 0.49340151308159397
#self.target_x = -0.16056636337579086 # produces nan for train_190730_1
#self.target_y = 0.49340151308159397

print('\ntarget: [{} {}]'.format(self.target_x, self.target_y))

Expand Down Expand Up @@ -106,10 +106,8 @@ def get_reward(self):


class Arm2DVecEnv(Arm2DEnv):
def reset(self, obs_as_dict=False, verbose=True, logfile='arm_log.txt'):
def reset(self, obs_as_dict=False, verbose=False, logfile='arm_log.txt'):
obs = super(Arm2DVecEnv, self).reset(obs_as_dict=obs_as_dict)
if np.isnan(obs).any():
obs = np.nan_to_num(obs)
self.verbose = verbose
if self.verbose:
self.log = Logfile(logfile)
Expand All @@ -120,9 +118,11 @@ def step(self, action, obs_as_dict=False):
obs, reward, done, info = super(Arm2DVecEnv, self).step(action, obs_as_dict=obs_as_dict)
if np.isnan(obs).any():
obs = np.nan_to_num(obs)
if self.verbose:
self.log.write(action)
self.log.write(obs)
done = True
reward -10
#if self.verbose:
# self.log.write(action)
# self.log.write(obs)
return obs, reward, done, info

class Logfile(object):
Expand Down

0 comments on commit 19f4a8c

Please sign in to comment.