Unverified Commit 5716d560 authored by Tyler Lum's avatar Tyler Lum Committed by GitHub

Fixes wait time in `play.py` by using `env.step_dt` (#2239)

# Description

When running `play.py` with `--real-time`, the dt used to calculate this
is incorrect. It is currently using `env.physics_dt`, which is `sim_dt`.
However, if the decimation is >1, then the effective dt is
`env.step_dt`, which is `sim_dt * decimation`. We are running 1
env.step() per loop, so this should definitely be `env.step_dt`.

This affects all reinforcement_learning/<rl_library>/play.py files. This
updates all of these appropriately

Fixes #2230 

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] (No need for test for small change in script) I have added tests
that prove my fix is effective or that my feature works
- [x] (No need for changelog in scripts) I have updated the changelog
and the corresponding version in the extension's `config/extension.toml`
file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
Signed-off-by: 's avatarTyler Lum <tylergwlum@gmail.com>
parent 07e45a97
...@@ -93,6 +93,7 @@ Guidelines for modifications: ...@@ -93,6 +93,7 @@ Guidelines for modifications:
* Shafeef Omar * Shafeef Omar
* Shundo Kishi * Shundo Kishi
* Stephan Pleines * Stephan Pleines
* Tyler Lum
* Victor Khaustov * Victor Khaustov
* Vladimir Fokow * Vladimir Fokow
* Wei Yang * Wei Yang
......
...@@ -152,7 +152,7 @@ def main(): ...@@ -152,7 +152,7 @@ def main():
agent.restore(resume_path) agent.restore(resume_path)
agent.reset() agent.reset()
dt = env.unwrapped.physics_dt dt = env.unwrapped.step_dt
# reset environment # reset environment
obs = env.reset() obs = env.reset()
......
...@@ -140,7 +140,7 @@ def main(): ...@@ -140,7 +140,7 @@ def main():
ppo_runner.alg.policy, normalizer=ppo_runner.obs_normalizer, path=export_model_dir, filename="policy.onnx" ppo_runner.alg.policy, normalizer=ppo_runner.obs_normalizer, path=export_model_dir, filename="policy.onnx"
) )
dt = env.unwrapped.physics_dt dt = env.unwrapped.step_dt
# reset environment # reset environment
obs, _ = env.get_observations() obs, _ = env.get_observations()
......
...@@ -134,7 +134,7 @@ def main(): ...@@ -134,7 +134,7 @@ def main():
print(f"Loading checkpoint from: {checkpoint_path}") print(f"Loading checkpoint from: {checkpoint_path}")
agent = PPO.load(checkpoint_path, env, print_system_info=True) agent = PPO.load(checkpoint_path, env, print_system_info=True)
dt = env.unwrapped.physics_dt dt = env.unwrapped.step_dt
# reset environment # reset environment
obs = env.reset() obs = env.reset()
......
...@@ -137,11 +137,11 @@ def main(): ...@@ -137,11 +137,11 @@ def main():
if isinstance(env.unwrapped, DirectMARLEnv) and algorithm in ["ppo"]: if isinstance(env.unwrapped, DirectMARLEnv) and algorithm in ["ppo"]:
env = multi_agent_to_single_agent(env) env = multi_agent_to_single_agent(env)
# get environment (physics) dt for real-time evaluation # get environment (step) dt for real-time evaluation
try: try:
dt = env.physics_dt dt = env.step_dt
except AttributeError: except AttributeError:
dt = env.unwrapped.physics_dt dt = env.unwrapped.step_dt
# wrap for video recording # wrap for video recording
if args_cli.video: if args_cli.video:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment