Skip to content

Commit 5c610f0

Browse files
authored
Fix teleop recording success term (#7571)
## Summary - keep an inert success termination registered while record_demos evaluates the original condition manually - preserve reward-manager references without allowing automatic success resets during demonstration capture - add a Franka Reach diffik startup regression test and changelog fragment ## Root cause record_demos removed the success termination before gym.make. The Franka Reach reward configuration now references that term through is_terminated_term, so reward-manager initialization could no longer resolve the success key and raised the regular-expression mismatch. ## Testing - verified the new regression test fails with the original behavior and the reported success: [] error - verified the regression test passes with the fix - uv run --frozen --extra teleop --with pytest python -m pytest source/isaaclab/test/cli/test_teleop_entrypoints.py -q - ./isaaclab.sh -f
1 parent c318019 commit 5c610f0

3 files changed

Lines changed: 40 additions & 7 deletions

File tree

scripts/tools/record_demos.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@
200200
_CLOUDXR_ENV_SHORTHANDS: dict[str, str] = {}
201201

202202

203+
def _never_terminate(env: gym.Env) -> torch.Tensor:
204+
"""Return a false termination signal for every environment."""
205+
return torch.zeros(env.num_envs, dtype=torch.bool, device=env.device)
206+
207+
203208
def _resolve_cloudxr_env(value: str | None, xr_enabled: bool = False) -> str | None:
204209
"""Resolve ``--cloudxr_env`` shorthands to absolute ``.env`` file paths.
205210
@@ -346,11 +351,12 @@ def create_environment_config(
346351
not teleop_device_explicitly_set and hasattr(env_cfg, "isaac_teleop") and env_cfg.isaac_teleop is not None
347352
)
348353

349-
# extract success checking function to invoke in the main loop
350-
success_term = None
351-
if hasattr(env_cfg.terminations, "success"):
352-
success_term = env_cfg.terminations.success
353-
env_cfg.terminations.success = None
354+
# Extract the success condition for manual evaluation in the main loop. Keep
355+
# an inert term registered under the same name so rewards and other manager
356+
# terms that reference "success" can still resolve it during initialization.
357+
success_term = getattr(env_cfg.terminations, "success", None)
358+
if success_term is not None:
359+
env_cfg.terminations.success = success_term.replace(func=_never_terminate, params={})
354360
else:
355361
logger.warning(
356362
"No success termination term was found in the environment."
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fixed
2+
^^^^^
3+
4+
* Fixed demonstration recording for tasks whose rewards reference the ``success``
5+
termination term.

source/isaaclab_teleop/test/test_teleop_scripts_smoke.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def _kit_dependencies(experience: Path) -> set[str]:
8282
"No module named 'omni.replicator'",
8383
"has no attribute 'enable_cameras'",
8484
"has no attribute 'headless'",
85+
# Success termination removed while a reward still references it
86+
"Not all regular expressions are matched",
8587
# Registry-only XR dependency: the app exits before any marker is printed
8688
"Exiting app because of dependency solver failure",
8789
)
@@ -95,6 +97,9 @@ def _kit_dependencies(experience: Path) -> set[str]:
9597
# Marker logged by ManagerBasedEnv creation, which runs *after* the RTX-apply site that regressed.
9698
_ENV_CREATED_MARKER = "Base environment:"
9799

100+
# Marker logged after every manager has initialized successfully.
101+
_ENV_READY_MARKER = "Completed setting up the environment"
102+
98103
# Disable CloudXR: no headset connects in CI, and auto-launching the runtime is unnecessary to
99104
# exercise the Isaac Teleop device factory (the live session is out of scope for a headless smoke).
100105
_NO_CLOUDXR = ["--cloudxr_env", "none", "--no-auto_launch_cloudxr"]
@@ -153,10 +158,10 @@ def _terminate_group(proc: subprocess.Popen) -> None:
153158

154159

155160
def _assert_started_cleanly(output: str, markers: list[str], script: str) -> None:
156-
"""Assert the run cleared the #6656 regression and reached a post-startup marker."""
161+
"""Assert the run cleared known regressions and reached a post-startup marker."""
157162
tail = output[-4000:]
158163
for sig in _REGRESSION_SIGNATURES:
159-
assert sig not in output, f"{script}: #6656 regression signature present ({sig!r})\n---\n{tail}"
164+
assert sig not in output, f"{script}: regression signature present ({sig!r})\n---\n{tail}"
160165
assert any(marker in output for marker in markers), (
161166
f"{script}: did not reach a startup marker {markers} within {_STARTUP_TIMEOUT_S:.0f}s\n---\n{tail}"
162167
)
@@ -199,6 +204,23 @@ def test_record_demos_starts(tmp_path):
199204
_assert_started_cleanly(output, [_ISAAC_TELEOP_MARKER], "record_demos.py")
200205

201206

207+
def test_record_demos_starts_when_reward_references_success(tmp_path):
208+
"""record_demos.py preserves success-term references while disabling automatic resets."""
209+
argv = [
210+
"scripts/tools/record_demos.py",
211+
"--task",
212+
"Isaac-Reach-Franka",
213+
"--teleop_device",
214+
"keyboard",
215+
"--dataset_file",
216+
str(tmp_path / "dataset.hdf5"),
217+
"physics=isaacsim_physx",
218+
"presets=diffik",
219+
]
220+
output = _launch_until_marker(argv, [_ENV_READY_MARKER], tmp_path / "record_demos_success_reward.log")
221+
_assert_started_cleanly(output, [_ENV_READY_MARKER], "record_demos.py with a success reward")
222+
223+
202224
def test_xr_experience_declares_only_shipped_extensions():
203225
"""The XR experience depends on XR extensions Isaac Sim ships, not on a registry-only bundle.
204226

0 commit comments

Comments
 (0)