2021-08-19 09:30:54 +02:00
|
|
|
import alr_envs
|
2021-07-01 14:55:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
def example_mp(env_name, seed=1):
|
|
|
|
"""
|
|
|
|
Example for running a motion primitive based version of a OpenAI-gym environment, which is already registered.
|
2022-06-29 09:37:18 +02:00
|
|
|
For more information on motion primitive specific stuff, look at the trajectory_generator examples.
|
2021-07-01 14:55:14 +02:00
|
|
|
Args:
|
2021-11-30 16:11:32 +01:00
|
|
|
env_name: ProMP env_id
|
2021-07-01 14:55:14 +02:00
|
|
|
seed: seed
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
"""
|
|
|
|
# While in this case gym.make() is possible to use as well, we recommend our custom make env function.
|
2021-08-19 09:30:54 +02:00
|
|
|
env = alr_envs.make(env_name, seed)
|
2021-07-01 14:55:14 +02:00
|
|
|
|
|
|
|
rewards = 0
|
|
|
|
obs = env.reset()
|
|
|
|
|
|
|
|
# number of samples/full trajectories (multiple environment steps)
|
|
|
|
for i in range(10):
|
|
|
|
ac = env.action_space.sample()
|
|
|
|
obs, reward, done, info = env.step(ac)
|
|
|
|
rewards += reward
|
|
|
|
|
|
|
|
if done:
|
|
|
|
print(rewards)
|
|
|
|
rewards = 0
|
|
|
|
obs = env.reset()
|
|
|
|
|
2021-08-19 09:30:54 +02:00
|
|
|
|
2021-07-01 14:55:14 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
# DMP - not supported yet
|
2021-08-19 09:30:54 +02:00
|
|
|
# example_mp("ReacherDMP-v2")
|
2021-07-01 14:55:14 +02:00
|
|
|
|
|
|
|
# DetProMP
|
2021-11-30 16:11:32 +01:00
|
|
|
example_mp("ContinuousMountainCarProMP-v0")
|
|
|
|
example_mp("ReacherProMP-v2")
|
|
|
|
example_mp("FetchReachDenseProMP-v1")
|
|
|
|
example_mp("FetchSlideDenseProMP-v1")
|