Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update random_policy.py to sample actions on GPU #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion omniisaacgymenvs/scripts/random_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ def parse_hydra_configs(cfg: DictConfig):
if env._world.is_playing():
if env._world.current_time_step_index == 0:
env._world.reset(soft=True)
actions = torch.tensor(np.array([env.action_space.sample() for _ in range(env.num_envs)]), device=task.rl_device)

# get upper and lower bounds of action space, sample actions randomly on this interval
action_high = env.action_space.high[0]
action_low = env.action_space.low[0]
actions = (action_high - action_low) * torch.rand(env.num_envs, env.action_space.shape[0]), device=task.rl_device) - action_high

env._task.pre_physics_step(actions)
env._world.step(render=render)
env.sim_frame_count += 1
Expand Down