-
Notifications
You must be signed in to change notification settings - Fork 1
/
runner.py
82 lines (63 loc) · 2.43 KB
/
runner.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
# import ddm_argparse
from test_ddm import vddm_env
import numpy as np
class EnvPlayer:
def __init__(self, env):
self.env = env
def play_motion_no_noise(self):
for i in range(self.env.num_frames):
obs = self.env.reset(i, False)
# print(self.env.should_terminate())
# print(env.reward(env.robot_skeleton, env.framenum))
self.env.render()
def take_single_step_zero_pos(self, init_frame=0):
obs = self.env.reset(init_frame, False)
self.env.step(np.zeros(self.env.action_dim))
def init_to_frame_passive(self, init_frame=0):
obs = self.env.reset(init_frame, 0, 0)
while True:
env.do_simulation(np.zeros(len(env.control_skel.q)),
env.simsteps_per_dataframe)
env.render()
if __name__ == "__main__":
# Don't run this as main, there's really not too much point
# parser = ddm_argparse.DartDeepMimicArgParse()
# args = parser.parse_args()
# env = parser.get_env()
env = vddm_env(3)
player = EnvPlayer(env)
player.play_motion_no_noise()
# env.reset(0, pos_stdv=args.pos_init_noise, vel_stdv=args.vel_init_noise)
# done = False
# i = 0
# rewards = []
# for i in range(len(env.ref_com_frames) -5 ):
# env.render()
# env.sync_skel_to_frame(env.control_skel, i, args.pos_init_noise,
# args.vel_init_noise)
# for k in range(10):
# rewards.append(env.reward(env.control_skel, i))
# env.do_simulation(np.zeros(56), 10)
# i += 1
# print(min(rewards))
# env.reset(0, False)
# env.reward(env.control_skel, 0)
# PID Test stuff
# start_frame = 0
# target_frame = 200
# env.sync_skel_to_frame(env.control_skel, target_frame, 0, 0)
# # print("Provided Target Q: \n", env.control_skel.q[6:])
# target_state = env.posveltuple_as_trans_plus_eulerlist(env.control_skel)
# pos, vel = target_state
# target_angles = pos[1][1:]
# # print("Provided Target Angles\n", target_angles)
# obs = env.sync_skel_to_frame(env.control_skel, start_frame, 0, 0)
# print(env.control_skel.dq)
# while True:
# env.framenum = target_frame
# s, r, done, info = env.step(np.concatenate(target_angles))
# env.render()
# frame = 0
# env.sync_skel_to_frame(env.control_skel, 0, 0, 0)
# while True:
# env.render()