Skip to content

[Task Clean-up][Manager] Dexterous Part 5/8: Add the reorientation manager counterparts#6418

Open
hujc7 wants to merge 4 commits into
isaac-sim:developfrom
hujc7:jichuanh/task-cleanup-dex-part08
Open

[Task Clean-up][Manager] Dexterous Part 5/8: Add the reorientation manager counterparts#6418
hujc7 wants to merge 4 commits into
isaac-sim:developfrom
hujc7:jichuanh/task-cleanup-dex-part08

Conversation

@hujc7

@hujc7 hujc7 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Review Map

PR Status Depends on Exact changes
#6410 [Docs] Environment overview regen
#6411 Part 1/8: Newton cloner/cubric/visualizer fixes
#6412 Part 2/8: OVPhysX articulation + manager runtime
#6413 Part 3/8: Reorient Direct, torch
#6414 Part 4/8: MARL-to-single-agent fix + handover/camera Direct #6413 changes
📌 #6418 Part 5/8: Reorient manager counterparts (this PR) #6413 changes
#6421 Part 6/8: Handover + camera manager counterparts #6413, #6414, #6418 changes
#6415 Part 7/8: Benchmark success-rate utilities + docs #6413, #6414, #6418, #6421 changes
#6582 Part 8/8: Warp variants → experimental (draft; merges last) #6413 changes
#6324 [DO-NOT-MERGE] Lumped validation reference ALL

Summary

  • Adds manager-based counterparts for the Allegro and Shadow cube reorientation tasks (state and OpenAI FF/LSTM variants), sharing the Direct tasks' scalar parameters and boolean success metrics through common MDP terms — consolidating the scope formerly tracked in [Task Clean-up][Manager] Dexterous Part 9/11: Add Shadow state and OpenAI manager counterparts #6419.
  • Breaking (major changelog fragment): the manager-based Allegro environment now matches the Direct contracts; existing manager checkpoints must be retrained. The legacy ReorientObjectEnvCfg and its terms are deprecated in favor of the Direct-compatible ones.

Stacking

Validation

@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR rewrites the Allegro Hand manager-based reorientation environment to match the Direct task's observation, action, reward, reset, termination, and success contracts, and adds a Newton physics preset. It lands the shared MDP terms (commands, events, observations, rewards, terminations) that the upcoming Shadow manager parts 9–11 will reuse.

  • allegro_hand_manager_env_cfg.py is rebuilt from scratch on top of AllegroHandEnvCfg and a new PresetCfg-backed scene supporting PhysX, Newton/MJWarp, and OV-PhysX backends.
  • New MDP files introduce Direct-compatible reset distributions, fingertip observations, the DirectReorientReward stateful term, and direct_reorient_timeout (prepared for Shadow configs).
  • Benchmark thresholds updated to match the retrained reference (reward 15 → 200, episode length 300 → 150).

Confidence Score: 4/5

Safe to merge for the Allegro scope; the direct_reorient_timeout side-effect concern must be resolved before the Shadow parts ship.

The Allegro config is solid and validated on both PhysX and Newton. The main concern is direct_reorient_timeout zeroing env.episode_length_buf inside a termination predicate — not active in this config but shared infrastructure for parts 9-11.

terminations.py and rewards.py deserve a second look before the Shadow manager parts adopt these helpers.

Important Files Changed

Filename Overview
source/isaaclab_tasks/isaaclab_tasks/core/reorient/mdp/terminations.py Adds object_reorientation_out_of_reach, direct_timeout, and direct_reorient_timeout; the last mutates env.episode_length_buf as a side effect inside a termination predicate.
source/isaaclab_tasks/isaaclab_tasks/core/reorient/mdp/rewards.py Adds Direct-compatible JIT reward helpers and the DirectReorientReward stateful manager term; partial-reset metric logging may produce misleading Metrics/success_rate values.
source/isaaclab_tasks/isaaclab_tasks/core/reorient/config/allegro_hand/allegro_hand_manager_env_cfg.py Full rewrite aligning the Allegro manager env to the Direct contract; adds Newton preset and set_num_envs helper with a minor redundant write through the default alias.
source/isaaclab_tasks/isaaclab_tasks/core/reorient/mdp/commands.py Adds ReorientEpisodeCommand delegating success accounting to the reward term; debug-vis callback allocates a tensor each frame.
source/isaaclab_tasks/isaaclab_tasks/core/reorient/mdp/observations.py Adds fingertip observations, the last-action helper, and OpenAIPolicyObservation with a stateful noise model; correct overall.
source/isaaclab_tasks/isaaclab_tasks/core/reorient/mdp/events.py New file adding reset_reorient_state; correctly mirrors the Direct task's reset distributions.
source/isaaclab_tasks/isaaclab_tasks/core/reorient/mdp/init.pyi Stub updated to export all new MDP symbols; complete and consistent.
source/isaaclab_tasks/test/benchmarking/configs.yaml Allegro benchmark thresholds updated consistent with the retrained reference.

Comments Outside Diff (1)

  1. source/isaaclab_tasks/isaaclab_tasks/core/reorient/mdp/commands.py, line 409-415 (link)

    P2 Per-call tensor allocation in hot visualization path

    _debug_vis_callback creates a new torch.tensor from cfg.fixed_marker_pos on every render frame. The tensor is identical each call; caching it in __init__ and reusing it here avoids repeated host-to-device allocation.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "Align the Allegro manager to the Direct ..." | Re-trigger Greptile

Comment on lines +100 to +131
def direct_reorient_timeout(
env: ManagerBasedRLEnv,
command_name: str,
reward_name: str,
success_tolerance: float,
max_successes: int,
object_cfg: SceneEntityCfg = SceneEntityCfg("object"),
) -> torch.Tensor:
"""Apply the Direct OpenAI progress-reset and timeout semantics.

Args:
env: Environment containing the object, goal, and reward term.
command_name: Goal command term name.
reward_name: Reorientation reward term name.
success_tolerance: Goal orientation tolerance [rad].
max_successes: Goals after which the episode terminates.
object_cfg: Object scene entity.

Returns:
Per-environment timeout flags.
"""
object_asset = env.scene[object_cfg.name]
target_quat = env.command_manager.get_command(command_name)[:, 3:7]
goal_reached, _ = evaluate_reorient_success(object_asset.data.root_quat_w.torch, target_quat, success_tolerance)
env.episode_length_buf = torch.where(
goal_reached,
torch.zeros_like(env.episode_length_buf),
env.episode_length_buf,
)
reward_term: DirectReorientReward = env.reward_manager.get_term_cfg(reward_name).func
max_success_reached = reward_term.successes >= max_successes
return (env.episode_length_buf >= env.max_episode_length - 1) | max_success_reached

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Side-effecting termination mutates shared episode state

direct_reorient_timeout writes directly to env.episode_length_buf inside what the framework expects to be a stateless predicate. When a goal is reached the counter is zeroed, which effectively hides elapsed time from every other termination term evaluated after this one in the same step. If a second fall or out-of-reach termination runs after this one, the reset can mask conditions that had been accumulating. The function is not wired into the current Allegro config (direct_timeout is used instead), but the PR description states it will be adopted by the Shadow manager parts 9–11, so the risk will materialize.

Comment on lines +226 to +235
def reset(self, env_ids: Sequence[int] | None = None) -> None:
if env_ids is None:
env_ids = slice(None)
threshold = self.cfg.params["success_count_threshold"]
self._env.extras.setdefault("log", {})["Metrics/success_rate"] = (
(self._successes[env_ids] >= threshold).float().mean().item()
)
for statistic, value in self._orientation_error.reset(env_ids).items():
self._env.extras["log"][f"Diagnostics/episode_min_orientation_error_{statistic}"] = value
self._successes[env_ids] = 0.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Partial-reset logging overwrites the global success-rate metric

reset is called with only the env_ids terminating in the current step; when a fraction of environments reset, the logged Metrics/success_rate reflects only that fraction and overwrites any earlier value from the same training step. Training dashboards may see a highly-variable or systematically biased metric depending on the batch composition at each reset boundary. Consider always computing the mean over all envs (ignoring env_ids) so the logged value is representative of the full population.

Comment on lines +103 to +108


@configclass
class ObservationsCfg:
"""Full 124-dimensional state observation in Direct order."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 set_num_envs double-writes the physx backend via its default alias

self.default is the same Python object as self.physx (assigned by default = physx), so self.default.num_envs = num_envs and self.physx.num_envs = num_envs are redundant. The second assignment is a no-op today but could confuse readers or silently break if default is ever re-pointed to a different backend.

Suggested change
@configclass
class ObservationsCfg:
"""Full 124-dimensional state observation in Direct order."""
def set_num_envs(self, num_envs: int) -> None:
"""Set the environment count on every backend alternative."""
self.physx.num_envs = num_envs
self.newton_mjwarp.num_envs = num_envs
self.ovphysx.num_envs = num_envs
self.default = self.physx

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Add a behavioral Metrics/success_rate signal (goal-reach streaks per
episode) and threshold-independent episode orientation-error diagnostics
to the Direct reorientation environments, with the shared helpers in
isaaclab_tasks.core.utils and torch math tests. The task logic is
torch-first per the mainline convention; success gates task health while
reward stays diagnostic. Also fix hand resets that could initialize
joints below their lower position limits.
@hujc7
hujc7 force-pushed the jichuanh/task-cleanup-dex-part08 branch from 3b4f0cc to d4d1290 Compare July 17, 2026 00:56
@hujc7 hujc7 changed the title [Task Clean-up][Manager] Dexterous Part 8/11: Align the Allegro manager to the Direct contract [Task Clean-up][Manager] Dexterous Part 8: Add the reorientation manager counterparts Jul 17, 2026
@hujc7 hujc7 changed the title [Task Clean-up][Manager] Dexterous Part 8: Add the reorientation manager counterparts [Task Clean-up][Manager] Dexterous Part 8/11: Align the Allegro manager to the Direct contract Jul 17, 2026
hujc7 added a commit that referenced this pull request Jul 17, 2026
…nager runtime (#6412)

## Summary

- Fixes OVPhysX actuator joint indices to follow the common actuator
indexing contract.
- Fixes OVPhysX initialization alongside Kit by reusing Kit's registered
PhysX schema provider.
- Fixes the OVPhysX manager to support both the declared public runtime
API and the current runtime API.
- Regression tests included. Validated by full dexterous training runs
on the OVPhysX backend; split out of the lumped validation branch #6324
(Part 2 of 11).

## Dependencies

- None.

## Series review map

Full integrated diff + training/validation evidence: the lumped
validation PR #6324
(DO-NOT-MERGE).

| Part | PR |
|---|---|
| Docs: regenerate the environment overview table |
#6410 |
| Part 1/11: Newton runtime fixes (cloner rows, cubric fallback, viz
teardown) | #6411 |
| **Part 2/11: OVPhysX runtime fixes (this PR)** |
#6412 |
| Part 3/11: success-rate metrics for the Direct reorientation tasks |
#6413 |
| Part 4/11: RSL-RL training for the handover Direct task |
#6414 |
| Part 5/11: success-rate support in the benchmark utilities |
#6415 |
| Part 6/11: renderer presets for the Direct camera task |
#6416 |
| Part 7/11: OVPhysX presets for the dexterous tasks |
#6417 |
| Part 8/11: Allegro manager counterpart |
#6418 |
| Part 9/11: Shadow + OpenAI manager counterparts |
#6419 |
| Part 10/11: Shadow camera manager counterpart |
#6420 |
| Part 11/11: Shadow handover manager counterpart |
#6421 |


---
### Exact changes in this PR

- OVPhysX backend changes + tests:
1f7a433
@hujc7 hujc7 changed the title [Task Clean-up][Manager] Dexterous Part 8/11: Align the Allegro manager to the Direct contract [Task Clean-up][Manager] Dexterous Part 5/8: Add the reorientation manager counterparts Jul 17, 2026
Fold the reviewed lump changes that belong to this part's content:

- Share per-family sim settings through task-cfg base mixins.
- Deduplicate backend scene presets via inner-class defaults and nest
  single-consumer helper cfgs in the shadow-hand Direct cfg.
- Compute the orientation error through
  isaaclab.utils.math.quat_error_magnitude and delete the local
  direct_reorient_rotation_distance primitive.
- Rename direct_reorient_reward to reorient_reward: shared symbols
  carry no paradigm prefix.

Source commits on the lump branch: 2c22af0, 792e400,
42675b6, c6140f9, 173e9dc.
@hujc7
hujc7 requested a review from pascal-roth as a code owner July 18, 2026 11:10
@hujc7
hujc7 requested a review from a team July 18, 2026 11:10
@hujc7
hujc7 force-pushed the jichuanh/task-cleanup-dex-part08 branch 3 times, most recently from 970a1cf to da863b8 Compare July 19, 2026 08:20
hujc7 added 2 commits July 20, 2026 15:32
Part 3 share of the lump readability round (cdaadac): the Direct
cfg files keep only task values; asset and marker cfgs, name lists,
backend presets, and noise cfgs move to shadow_hand_common and
allegro_hand_common, task geometry to reorient_common, and
reorient_task_base is removed. The Shadow Direct files carry the
workflow marker in their names.
Rebuilt from the reviewed lump so the manager counterparts land with
the review rounds folded in: inline section values per file (drift
guarded by the value-parity test incl. sim), identity from the common
modules, the OpenAI variant in its own module, and no sim mixins.

Lump review commits folded: 2c22af0, 792e400, 42675b6,
1f05f85, c6140f9, 173e9dc, 2727616, 1732493,
3659a33, ee272c9, cdaadac.
@hujc7
hujc7 force-pushed the jichuanh/task-cleanup-dex-part08 branch from da863b8 to 957322a Compare July 20, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant