forked from divyamrast/Learning-via-Difference-Models
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgait_analysis.py
105 lines (83 loc) · 3.67 KB
/
gait_analysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from ddpg import parse_args, cfg_run
import os
stage_names = ('00_balancing_tf', '01_balancing', '02_walking')
def main():
folder = 'gait_analysis/'
policies = folder + 'policies/'
trajectories = folder + 'trajectories/'
misc = folder + 'misc/'
# for mp in range(6):
# leo_export(mp, task='balancing', policies=policies, trajectories=trajectories, misc=misc)
# leo_export(mp, task='walking', policies=policies, trajectories=trajectories, misc=misc)
# mujoco_export('Walker2d', 1, task='Balancing', policies=policies, trajectories=trajectories, misc=misc)
# mujoco_export('Hopper', 2, task='Walking', policies=policies, trajectories=trajectories, misc=misc)
# mujoco_export('HalfCheetah', 0, task='Balancing', policies=policies, trajectories=trajectories, misc=misc)
# mujoco_export('HalfCheetah', 0, task='Walking', policies=policies, trajectories=trajectories, misc=misc)
mujoco_models = ['Hopper', 'HalfCheetah', 'Walker2d']
mujoco_models = ['Hopper']
for env in mujoco_models:
for mp in range(6):
#mujoco_export(env, mp, task='Balancing', policies=policies, trajectories=trajectories, misc=misc)
mujoco_export(env, mp, task='Walking', policies=policies, trajectories=trajectories, misc=misc)
def mujoco_export(env, mp, task='Walking', policies='', trajectories='', misc=''):
args = parse_args()
if task == 'Balancing':
task_balancing = task
else:
task_balancing = ''
args['cfg'] = "Roboschool{}-v1".format(env+task_balancing+'GRL')
args['steps'] = 0
args['trials'] = 1
args['test_interval'] = 0
args['normalize_observations'] = False
args['normalize_returns'] = False
args['batch_norm'] = True
args['render'] = True
args['output'] = misc + '{}_{}_play-mp{}'.format(env.lower(), task.lower(), mp)
t = task[0].lower()
if t == 'b':
stage = stage_names[1]
elif t == 'w':
stage = stage_names[2]
else:
raise ValueError('incorrect task ' + task)
args['load_file'] = policies + 'ddpg-exp1_two_stage_{env}_ga_{task}-g0001-mp{mp}-{stage}'.format(
env=env.lower(), task=t, mp=mp, stage=stage)
args['compare_with'] = policies + 'ddpg-exp1_two_stage_{env}_ga_b-g0001-mp{mp}-01_balancing-last'.format(
env=env.lower(), mp=mp)
args['trajectory'] = trajectories + '{}_{}-mp{}'.format(env.lower(), task.lower(), mp)
args['env_timestep'] = 0.0165
# Run actual script.
args['save'] = False
cfg_run(**args)
def leo_export(mp, policies='', task='walking', trajectories='', misc=''):
args = parse_args()
env = 'leo'
args['cfg'] = 'cfg/{}_{}_play.yaml'.format(env, task)
args['steps'] = 0
args['trials'] = 1
args['test_interval'] = 0
args['normalize_observations'] = False
args['normalize_returns'] = False
args['batch_norm'] = True
args['output'] = misc + '{}_{}_play-mp{}'.format(env, task, mp)
t = task[0].lower()
if t == 'b':
stage = stage_names[1]
elif t == 'w':
stage = stage_names[2]
else:
raise ValueError('incorrect task ' + task)
args['load_file'] = policies + 'ddpg-exp1_two_stage_leo_ga_{task}-g0001-mp{mp}-{stage}'.format(task=t, mp=mp, stage=stage)
args['compare_with'] = policies + 'ddpg-exp1_two_stage_leo_ga_b-g0001-mp{mp}-01_balancing-last'.format(mp=mp)
args['trajectory'] = trajectories + '{}_{}-mp{}'.format(env, task, mp)
args['env_timestep'] = 0.03
# Run actual script.
args['save'] = False
cfg_run(**args)
if task == 'walking':
os.rename('aux_leo.csv', 'aux_leo-mp{}.csv'.format(mp))
if __name__ == '__main__':
main()