fancy_gym/dmp_env_wrapper_example.py

36 lines
1.3 KiB
Python
Raw Normal View History

2021-02-15 09:03:19 +01:00
from alr_envs.classic_control.utils import make_viapointreacher_env
2021-04-07 18:18:51 +02:00
from alr_envs.classic_control.utils import make_holereacher_env, make_holereacher_fix_goal_env, make_holereacher_env_pmp
2021-02-15 09:03:19 +01:00
from alr_envs.utils.dmp_async_vec_env import DmpAsyncVectorEnv
2021-01-11 16:08:42 +01:00
import numpy as np
if __name__ == "__main__":
2021-02-17 17:48:05 +01:00
n_samples = 1
2021-02-15 09:03:19 +01:00
n_cpus = 4
2021-04-10 13:25:08 +02:00
dim = 30
2021-01-11 16:08:42 +01:00
2021-02-17 17:48:05 +01:00
# env = DmpAsyncVectorEnv([make_viapointreacher_env(i) for i in range(n_cpus)],
# n_samples=n_samples)
2021-04-10 13:25:08 +02:00
test_env = make_holereacher_env(0)()
2021-04-07 18:18:51 +02:00
# params = 1 * np.random.randn(dim)
2021-04-10 13:25:08 +02:00
params = np.array([ -1.09434772, 7.09294269, 0.98756352, 1.61950682,
2.66567135, 1.71267901, 8.20010847, 2.50496653,
-0.34886972, 2.07807773, 8.68615904, 3.66578556,
5.24572097, -3.21506848, -0.28593896, 17.03756855,
-5.88445032, 6.02197609, -3.73457261, -4.24772663,
8.69382861, -10.99939646, 5.31356886, 8.57420996,
1.05616879, 19.79831628, -23.53288774, -3.32974082,
-5.86463784, -9.68133089])
2021-02-19 16:17:55 +01:00
2021-02-15 09:03:19 +01:00
# params = np.hstack([50 * np.random.randn(n_samples, 25), np.tile(np.array([np.pi/2, -np.pi/4, -np.pi/4, -np.pi/4, -np.pi/4]), [n_samples, 1])])
2021-01-11 16:08:42 +01:00
2021-04-10 13:37:48 +02:00
rew, info = test_env.rollout(params, render=False)
2021-02-19 16:17:55 +01:00
print(rew)
2021-01-11 16:08:42 +01:00
2021-02-17 17:48:05 +01:00
# out = env(params)
# print(out)