Skip to content

Commit 5716d56

Browse files
authored
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: Tyler Lum <[email protected]>
1 parent 07e45a9 commit 5716d56

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Guidelines for modifications:
9393
* Shafeef Omar
9494
* Shundo Kishi
9595
* Stephan Pleines
96+
* Tyler Lum
9697
* Victor Khaustov
9798
* Vladimir Fokow
9899
* Wei Yang

scripts/reinforcement_learning/rl_games/play.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def main():
152152
agent.restore(resume_path)
153153
agent.reset()
154154

155-
dt = env.unwrapped.physics_dt
155+
dt = env.unwrapped.step_dt
156156

157157
# reset environment
158158
obs = env.reset()

scripts/reinforcement_learning/rsl_rl/play.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def main():
140140
ppo_runner.alg.policy, normalizer=ppo_runner.obs_normalizer, path=export_model_dir, filename="policy.onnx"
141141
)
142142

143-
dt = env.unwrapped.physics_dt
143+
dt = env.unwrapped.step_dt
144144

145145
# reset environment
146146
obs, _ = env.get_observations()

scripts/reinforcement_learning/sb3/play.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def main():
134134
print(f"Loading checkpoint from: {checkpoint_path}")
135135
agent = PPO.load(checkpoint_path, env, print_system_info=True)
136136

137-
dt = env.unwrapped.physics_dt
137+
dt = env.unwrapped.step_dt
138138

139139
# reset environment
140140
obs = env.reset()

scripts/reinforcement_learning/skrl/play.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ def main():
137137
if isinstance(env.unwrapped, DirectMARLEnv) and algorithm in ["ppo"]:
138138
env = multi_agent_to_single_agent(env)
139139

140-
# get environment (physics) dt for real-time evaluation
140+
# get environment (step) dt for real-time evaluation
141141
try:
142-
dt = env.physics_dt
142+
dt = env.step_dt
143143
except AttributeError:
144-
dt = env.unwrapped.physics_dt
144+
dt = env.unwrapped.step_dt
145145

146146
# wrap for video recording
147147
if args_cli.video:

0 commit comments

Comments
 (0)