Repository navigation
Add zero agent and random agent into CLI - #6793
Conversation
There was a problem hiding this comment.
Isaac Lab Review Bot
No material issues were identified in the reviewed diff.
- Design and architecture: No material concerns.
- API: No material concerns.
- Implementation: No material concerns.
Ship it. No actionable findings were identified in the reviewed diff.
Conservative automated review; human maintainers own approval decisions.
Greptile SummaryAdds reusable zero-action and random-action agent entrypoints and exposes them through the Isaac Lab CLI.
Confidence Score: 5/5The PR appears safe to merge with no concrete changed-code failures identified. The new CLI and typed API paths preserve launcher and Hydra argument handling, defer simulation startup appropriately, and route both compatibility scripts through the shared implementation. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
CLI["isaaclab zero_agent / random_agent"] --> Shim["scripts/environments/*_agent.py"]
API["SimpleAgentRequest API"] --> Dispatch["isaaclab_rl.entrypoints dispatch"]
Shim --> Dispatch
Dispatch --> Runner["simple_agents.run"]
Runner --> Config["Resolve task and simulation config"]
Config --> Env["gym.make(task)"]
Env --> Loop["Apply zero or random actions"]
Reviews (1): Last reviewed commit: "Add zero agent and random agent" | Re-trigger Greptile |
hujc7
left a comment
There was a problem hiding this comment.
Agent review: nice consolidation -- one implementation behind three thin layers (typed request, CLI dispatcher, executables), matching the existing train/play shape.
Verified locally: pre-commit clean across all 15 changed files; the cartpole/__init__.py literalinclude line numbers land on both gym.register blocks.
Important
Blocker -- the new --num_envs default of 4 is applied unconditionally, so an explicit env.scene.num_envs=<N> on the command line is silently discarded. Details inline on simple_agents.py.
Also inline: a loop simplification that closes an exit-path gap in the new public API, and one typing nit.
Beyond the diff: no CI job or test exercises either agent end-to-end -- the delegation test asserts on file text only, so the new command paths are unexercised.
|
|
||
| with launch_simulation(env_cfg, args_cli): | ||
| # override with CLI arguments | ||
| env_cfg.scene.num_envs = args_cli.num_envs |
There was a problem hiding this comment.
Agent found bug: --num_envs defaults to 4 (line 111) and is applied unconditionally here, so an explicit Hydra override is silently discarded.
$ isaaclab zero_agent --task Isaac-Cartpole env.scene.num_envs=64
# runs 4 environments, not 64 -- no warningWhy: resolve_task_config applies Hydra overrides to env_cfg before this line, so the assignment overwrites them. That override form is live in the repo -- test_preset_kit_decision.py uses env.scene.num_envs=123, benchmark_hydra_resolve.py uses env.scene.num_envs=256.
Divergence from the package convention:
| Entrypoint | argparse default | assignment |
|---|---|---|
play_sb3.py |
None |
guarded |
play_rl_games.py |
None |
guarded |
play_skrl.py |
None |
guarded |
simple_agents.py (this PR) |
4 |
unguarded |
Fix -- two lines; applying either alone leaves the bug live:
@@ line 111 @@
- parser.add_argument("--num_envs", type=int, default=_DEFAULT_NUM_ENVS, help="Number of environments to simulate.")
+ parser.add_argument("--num_envs", type=int, default=None, help="Number of environments to simulate.")
@@ line 69 @@
- env_cfg.scene.num_envs = args_cli.num_envs
+ env_cfg.scene.num_envs = args_cli.num_envs if args_cli.num_envs is not None else env_cfg.scene.num_envsThis also drops the 4-environment default, which reads as a change separate from moving the agents into the CLI.
Alternative -- keep the small default, but let it lose to an explicit override
Requires _parse_args to also return hydra_args:
if args_cli.num_envs is not None:
env_cfg.scene.num_envs = args_cli.num_envs
elif not any(arg.startswith("env.scene.num_envs=") for arg in hydra_args):
env_cfg.scene.num_envs = _DEFAULT_NUM_ENVSDone when isaaclab zero_agent --task Isaac-Cartpole env.scene.num_envs=64 reports 64 environments.
| sim = env.unwrapped.sim | ||
| device = env.unwrapped.device | ||
| zero_actions = torch.zeros(env.action_space.shape, device=device) | ||
| while True: |
There was a problem hiding this comment.
Agent review: two observations on this loop.
1. It re-implements an existing helper. SimulationContext.is_headless_or_exist_active_visualizer() is the exact negation of the break condition, and is already the idiom in ~18 scripts under scripts/demos/:
- while True:
- if sim.visualizers:
- # visualizer mode: run until the visualizer window is closed
- if not any(v.is_running() and not v.is_closed for v in sim.visualizers):
- break
- # run everything in inference mode
+ # step while a visualizer window is still open (or none exist, e.g. headless)
+ while sim.is_headless_or_exist_active_visualizer():
with torch.inference_mode():2. With --viz none there is no exit path at all. _resolve_visualizer_cfgs returns [] when visualizers are disabled, initialize_visualizers then returns early leaving _visualizers empty, so if sim.visualizers: is never true and the break is unreachable.
That was tolerable while these were only scripts. It matters more now: zero_agent() and random_agent() in api.py are documented to return a process exit code, and under --viz none they cannot return.
The deleted MAX_STEPS = 100 was the vestige of that bound -- it was never wired up. A --max_steps argument would restore it, matching scripts/demos/sensors/ppisp_camera.py and the MPM demos. It would also make these commands cheap to smoke-test, since nothing in .github/, tools/, or the test suites currently executes either agent.
| return _run_simple_agent_cli("random", argv) | ||
|
|
||
|
|
||
| def _run_simple_agent_cli(policy: str, argv: list[str] | None) -> int: |
There was a problem hiding this comment.
Agent suggestion: policy is typed str here, but simple_agents.run() declares policy: PolicyName.
The module already has from __future__ import annotations, so the alias imports under TYPE_CHECKING with no change to import cost:
import argparse
import importlib
import runpy
import sys
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from .simple_agents import PolicyName| def _run_simple_agent_cli(policy: str, argv: list[str] | None) -> int: | |
| def _run_simple_agent_cli(policy: PolicyName, argv: list[str] | None) -> int: |
Restore the guarded --num_envs assignment so an explicit env.scene.num_envs Hydra override is no longer silently discarded, and drop the 4-environment default that shadowed it. Replace the hand-rolled visualizer loop with SimulationContext.is_headless_or_exist_active_visualizer() and add a --max_steps bound so the agents terminate under --viz none, where the public zero_agent()/random_agent() APIs previously could never return.
# Description Adds the zero agent and random agent into our isaaclab cli workflow. Existing scripts are left behind as stubs. `uv run isaaclab zero_agent --task` `uv run isaaclab random_agent --task` ## Checklist - [ ] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump `extension.toml` — CI handles that) - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there <!-- As you go through the checklist above, you can mark something as done by putting an x character in it For example, - [x] I have done this task - [ ] I have not done this task -->
# Description Moves `teleop_se3_agent.py`, `record_demos.py` and `teleop_replay_agent.py` into `isaaclab_teleop.entrypoints`, following the `isaaclab_rl.entrypoints` pattern (#6553, #6793), and untangles `record_demos.py` from `isaaclab_mimic`, which is slated for deprecation. - **Entrypoints:** `run_teleop_se3_agent_cli`, `run_record_demos_cli` and `run_teleop_replay_agent_cli` take the command line without the program name. The function bodies are unchanged; the argument parsing that ran at import time becomes `_parse_args(argv)`. Git tracks the modules as renames, so review with rename detection. - **Scripts kept as thin wrappers** at their current paths (same shape as `random_agent.py`), so documented commands and the wheel staging list keep working. - **`isaaclab teleop run|record` call the entrypoints in process,** like `isaaclab train`, instead of launching the scripts. `replay` still runs `scripts/tools/replay_demos.py`, which is not moved. - **Out-of-tree tasks:** each entrypoint calls `load_external_tasks()` before parsing, so tasks registered through the `isaaclab.tasks` entry point work with the scripts and `isaaclab teleop`. - **Mimic untangled from `record_demos.py`:** - Mimic task variants (`*-Mimic-v0`) are registered only when `isaaclab_mimic` is installed. - The instruction display, whose only user was `record_demos.py`, moves from `isaaclab_mimic.ui` into the entrypoints package as a private module. - Without Kit the display has no labels and shows nothing, replacing the `SimpleNamespace` stand-ins from #8828. Notes for review: - The entrypoints import `isaaclab_tasks` without `isaaclab_teleop` declaring it. Declaring it would create a cycle, since `isaaclab_tasks` imports `isaaclab_teleop`; the import only happens when a CLI function runs. - The instruction display moves from isaaclab_mimic with its original Apache-2.0 and BSD-3-Clause notices; .pre-commit-config.yaml licenses it like the mimic files so the header hooks keep them. - The modules keep a module-level `args_cli`, so the moved functions stay unchanged. Passing it explicitly, as the RL backends do, is left for a follow-up. ## Type of change - New feature (non-breaking change which adds functionality) - Breaking change (`isaaclab_mimic.ui.instruction_display` is removed; its only user was `record_demos.py`) ## Checklist Docker and GPU tests run on demand. Push the commits you want tested, then comment `run-ci` on the pull request. - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `uv run isaaclab --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the [test-audit criteria](https://github.com/isaac-sim/IsaacLab/blob/HEAD/skills/developer/test-audit/SKILL.md) to any test changes - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump package versions — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: Rafael Wiltz <[email protected]>
Description
Adds the zero agent and random agent into our isaaclab cli workflow. Existing scripts are left behind as stubs.
uv run isaaclab zero_agent --taskuv run isaaclab random_agent --taskChecklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there