fancy_gym/dmp_env_wrapper_example.py

31 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-03-19 16:31:46 +01:00
from alr_envs.classic_control.utils import make_holereacher_env, make_holereacher_fix_goal_env
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-03-19 16:31:46 +01: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-03-19 16:31:46 +01:00
test_env = make_holereacher_env(0)()
2021-02-11 12:32:32 +01:00
2021-02-19 16:17:55 +01:00
# params = np.random.randn(n_samples, dim)
params = np.array([[1.386102, -3.29980525, 4.70402733, 1.3966668, 0.73774902,
3.14676681, -4.98644416, 6.20303193, 1.30502127, -0.09330522,
7.62656797, -5.76893033, 3.4706711, -0.6944142, -3.33442788,
12.31421548, -0.72760271, -6.9090723, 7.02903814, -8.7236836,
1.4805914, 0.53185824, -5.46626893, 0.69692163, 13.58472666,
0.77199316, 2.02906724, -3.0203244, -1.00533159, -0.57417351]])
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-02-19 16:17:55 +01:00
rew, info = test_env.rollout(params, render=True)
print(rew)
2021-01-11 16:08:42 +01:00
2021-02-17 17:48:05 +01:00
# out = env(params)
# print(out)