Skip to content

Conversation

@808brick
Copy link

@808brick 808brick commented Feb 1, 2026

The termination_manager expects a tensor of [1] but the previous view setup was creating a tensor of [1,1] causing the IsaacLab sim/task to crash

Description

Changed the view shape in line 63 of terminations.py from

suction_cup_status = surface_gripper.state.view(-1, 1) 

to

suction_cup_status = surface_gripper.state.view(-1) 

Which provided the correct tensor shape expected by termination_manager.py

Fixes # 4506

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Before

Screenshot from 2026-01-31 19-25-22

After

Screenshot from 2026-01-31 19-22-44

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation [Not Needed, should return normal functionality]
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works [Open To Feedback Here]
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there [Not Needed]

The termination_manager expects a tensor of [1] but the previous view setup was creating a tensor of [1,1] causing the IsaacLab sim/task to crash

Signed-off-by: Raymond Andrade <raymond808state1@gmail.com>
Fix suction cup status tensor shape in terminations.py
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 1, 2026

Greptile Overview

Greptile Summary

Changed surface_gripper.state.view(-1, 1) to surface_gripper.state.view(-1) in the cubes_stacked termination function to fix a tensor shape mismatch.

Key Changes:

  • Fixed tensor reshape from [num_envs, 1] to [num_envs] on line 63
  • The TerminationManager expects termination functions to return boolean tensors of shape [num_envs] (1D), not [num_envs, 1] (2D)
  • This resolves the crash when the termination manager tries to store the result in _term_dones[:, i]

Additional Notes:

  • The same pattern exists in place/mdp/terminations.py at lines 53 and 101, which may need the same fix
  • The observation functions in stack/mdp/observations.py correctly use .view(-1, 1) since observations have different shape requirements

Confidence Score: 4/5

  • Safe to merge - fixes a clear shape mismatch bug with minimal risk
  • The fix is correct and addresses a real bug. The change is minimal (removing one dimension from tensor reshape) and directly resolves the shape mismatch between what the termination function returns and what TerminationManager expects. However, there appear to be similar issues in other files that may need attention.
  • Check place/mdp/terminations.py for similar shape issues at lines 53 and 101

Important Files Changed

Filename Overview
source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/stack/mdp/terminations.py Fixed tensor shape from [num_envs, 1] to [num_envs] to match TerminationManager requirements

Sequence Diagram

sequenceDiagram
    participant Env as ManagerBasedRLEnv
    participant TM as TerminationManager
    participant CT as cubes_stacked()
    participant SG as SurfaceGripper
    
    Env->>TM: compute()
    TM->>CT: call termination function
    CT->>SG: surface_gripper.state
    SG-->>CT: raw state tensor
    CT->>CT: view(-1) reshape to [num_envs]
    CT->>CT: compare with -1 (open state)
    CT->>CT: logical_and with stacked condition
    CT-->>TM: boolean tensor [num_envs]
    TM->>TM: store in _term_dones[:, i]
    TM-->>Env: combined termination signal [num_envs]
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

if hasattr(env.scene, "surface_grippers") and len(env.scene.surface_grippers) > 0:
surface_gripper = env.scene.surface_grippers["surface_gripper"]
suction_cup_status = surface_gripper.state.view(-1, 1) # 1: closed, 0: closing, -1: open
suction_cup_status = surface_gripper.state.view(-1) # 1: closed, 0: closing, -1: open
Copy link
Contributor

Choose a reason for hiding this comment

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

Same shape issue exists in place/mdp/terminations.py lines 53 & 101 - check if those need the same fix

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