Skip to content

Commit

Permalink
fixed myosuite baseline example for gymnasium
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Schumacher committed Jul 10, 2024
1 parent b9c0657 commit 2217d0e
Show file tree
Hide file tree
Showing 4 changed files with 1,079 additions and 865 deletions.
12 changes: 5 additions & 7 deletions examples/example_load_baseline_myosuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,36 @@

import time

import gym
import myosuite # noqa
from myosuite.utils import gym

import deprl

# create the sconegym env
env = gym.make("myoChallengeChaseTagP1-v0")
env = gym.make("myoLegWalk-v0", reset_type="random")
policy = deprl.load_baseline(env)

env.seed(0)
for ep in range(10):
ep_steps = 0
ep_tot_reward = 0
state = env.reset()
state, _ = env.reset()

while True:
# samples random action
action = policy(state)
# applies action and advances environment by one step
state, reward, done, info = env.step(action)
state, reward, terminated, truncated, info = env.step(action)

ep_steps += 1
ep_tot_reward += reward
env.mj_render()
time.sleep(0.01)

# check if done
done = terminated or truncated
if done or (ep_steps >= 1000):
print(
f"Episode {ep} ending; steps={ep_steps}; reward={ep_tot_reward:0.3f};"
)
env.reset()
break

env.close()
Loading

0 comments on commit 2217d0e

Please sign in to comment.